0

dictionary

def nameID(): for i in range (5): name =input( "name : ") id = int(input("Id : ")) nameid = {} nameid[name] = id nameID() Hello I want to add a key value for this dict with for loop but it doesnt work whats problem?

7th Jun 2020, 6:26 AM
nima rasi
2 ответов
+ 4
nameid = {} move this outside the loop You also don't print or return anything from the function, so there isn't any output.
7th Jun 2020, 6:31 AM
ChaoticDawg
ChaoticDawg - avatar
+ 1
it works thanks
7th Jun 2020, 6:33 AM
nima rasi