Q. Find errors, underline them and rewrite the same after correcting the following code:-


d1 = dict[]

i = 1

n = input ("Enter number of entries : ")

while i <= n :

    a = input ("Enter name:")

    b = input ("Enter age:")

    d1 (a) = b

    i = i + 1

l = d1.key []

for i in l :

    print (i, '\t', 'd1[ i ]')


Answer =

d1 = dict ()
i = 1
n = int (input ("Enter number of entries:"))
while i <= n :
    a = input ("Enter name:")
    b = int (input ("Enter age:"))
    d1[ a ] = b
    i = i + 1

l = d1.keys ()
for i in l :
    print(i, '\t', d1[i])

Post a Comment

You can help us by Clicking on ads. ^_^
Please do not send spam comment : )

Previous Post Next Post