Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Init the empty dictionary
- dct = {}
- while True:
- # Ask for a name.
- name = raw_input("Enter a name or an empty string to stop: ")
- # If the given name is empty string, break the loop.
- if name == '':
- break
- # Ask for an age.
- age = int(input("Enter age: "))
- # Add user input to the dictionary. Name as key, age as value.
- dct[name] = age
- print(dct)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement