I'm new to python while loop and dictionary.
I want to write a code sample that prompts repeatedly prompts the user for a key followed by a value. The key and value should then be stored in a dictionary.
It should stop prompting the user for keys and values once the user enters the word "Done" as a key followed by "Done" as a value. We may assume that the user will only enter string-type keys and string-type values. We also do not need to worry about duplicate keys.
After the user types "Done" for value and "Done" for key, the code sample should then prompt the user for one lookup key. It will print out the value of that key and finish.
See below for examples...
Example
Key: Tu
Value: Tuesday
Key: We
Value: Wednesday
Key: Th
Value: Thursday
Key: Fr
Value: Done
Key: Sa
Value: Saturday
Key: Done
Value: Done
What would you like to look up? Fr
Done
My codes (how to fix it?):
a = input('Key: ')
b = input('Value: ')
dict = {a: b}
while a != 'Done' and b != 'Done':
new_dict = {input('Key: '): input('Value: ')}
dict.update(new_dict)
key = input('What would you like to look up?')
print(dict.get(key))