I have to take inputs from a user and assign it to a dictionary in Python.
Inputs: 5 2000 8 1000 9 5000 10 2000 9 1000 8
Explanation: 5 is the total number of inputs which the user will input. So this doesn't need to be stored in a dictionary.
Other values like "2000 8" need to be stored in a dictionary. Here "2000" is the key and "8" is the value. when the same key has the same values ("2000 8" and "2000 9") the key with the lowest value will be returned as an output.
I tried doing this:
mydict = {}
for totnum in range(0,int(input('Input the total number'))):
a, b = input('Enter the key value pair').split()
mydict[a] = [b]
print(mydict)
But this is wrong because in case of duplicate keys (say "2000 8" and "2000 9") it will always store the last input by the user.
How can I store multiple values to the same key in a dictionary?