n_passid= {} #this is where we save the new input taken from the user.
k= input("give me a userid")
y= input("give me a pass")
n_passid.update({(k) : (y)}) # i'm passing in k's value as the key for the new dict and y as the value of the key k.
n_passid #this is to print the dict.
#this also works
n_passid= {} #this is where we save the new input taken from the user.
k= input("give me a userid")
y= input("give me a pass")
n_passid.update( k = y) #i didnt use the curly bracket here. using this method, you can update multiple key values
n_passid
No comments:
Post a Comment