Jun-25-2020, 10:18 AM
(This post was last modified: Jun-25-2020, 02:35 PM by glennford49.)
i dont know what is the correct approach , for each loop or for i, i dont have any idea,
all i need is to loop the dictionary to get each keys as list item
all i need is to loop the dictionary to get each keys as list item
users={"glenn":1,"elena":2,"mama":3} names=(list(users.keys())) for i in names: # for each ? i dont know what is the correct approach of this # i should become a list of each 3 keys in a dictionay i=list(i) print(type(i)) print(type(glenn)) # confirming if its a list but, i think its impossible coz its outside of the for loopi think i cannot make print a list that is outside of the for loop in this situation
users={"glenn":1,"elena":2,"mama":3} names=(list(users.keys())) namelist=[] for i in names: print(i) namelist.append(i) print(namelist)i think this is all ive got,, thanks for your time,