+ 4
Devender singh You have to convert input to integer as you are using in range so do this n = int(input()) input() returns String so you have to cast with int to get integer value so here is complete code ------------------- a = {} n = int(input("no.of element:\n")) for i in range(n): k = input("enter key:\n") v = input("enter value:\n") a.update({k : v}) print(a) ---------------------- And also take input like this: 2 #here 2 is no of keys, value pair ab cd ef gh
23rd May 2021, 6:41 AM
AÍąJ
AÍąJ - avatar