take input for dictionary in python code example

Example 1: how to take input for dictionary in python

for i in range(3):
    data = input().split(' ')
    d[data[0]] = int(data[1])

Example 2: python dictionary input

class_list = dict() data = input('Enter name & score separated by ":" ') temp = data.split(':') class_list[temp[0]] = int(temp[1])  # Displaying the dictionary for key, value in class_list.items(): 	print('Name: {}, Score: {}'.format(key, value))

Example 3: dictionary input from user in python3

d=dict(input().split() for x in range(n))
print(d)