Jul-28-2018, 12:39 PM
Have been trying to learn about dictionaries in Python 3 at Understanding Dictionaries in Python 3
# Define original dictionary
usernames = {'Sammy': 'sammy-shark', 'Jamie': 'mantisshrimp54'}
# Set up while loop to iterate
while True:
# Request user to enter a usernames
print('Enter a name:')
# Assign to name variable
name = input()
# Check whether name is in the dictionary and print feedback
if name in usernames:
print(usernames[name] + ' is the name of ' + name)
# If the name is not in the dictionary...
else:
#provide feedback
print('I don\'t have ' + name + '\'s username, what is it?')
# Take in a new username for the associated username
username = input()
# Assign username value to name key
usernames[name] = usernames
# Print feedback that the data was updated
print('Data updated.')But when i try to close the program using Ctrl + C i get the following error:^CTraceback (most recent call last)
File "/home/oldDog/usernames.py", line 13, in <module>
name = input()
KeyboardInterruptCould someone help me please
