Good afternoon :)
Generally such a trouble.I just can’t figure out how to get rid of the for loop in a dictionary that is in a dictionary.
#- * - coding: utf-8 - * -
#Code By Rishat
DB with accounting: D
l1={"user1": {"Name": None,"Fname": None,"Zarplata": None,"Age": None},"user2": {"Name": None,"Fname": None,"Zarplata": None,"Age": None},"user3": {"Name": None,"Fname": None,"Zarplata": None,"Age": None}}
for loginr in l1:
    print l1[loginr]
    for loginr in l1["user1"]:
        print l1[loginr]
print u"End"

The first cycle works with a bang :) And how to implement another cycle correctly? In my case, the second loop should output the entire value from the user keys.

1 Answers 1

You have variables in the two cycles are called the same(loginr) and one key is missing in the second cycle.Here it works, but I still do not understand what it should do.What is the goal of the task?

l1={"user1": {"Name": None,"Fname": None,"Zarplata": None,"Age": None}," user2": {" Name": None," Fname": None," Zarplata": None," Age": None}," user3": {" Name": None," Fname": None," Zarplata": None,"Age": None}}
for login_key, login_value in l1.items():
    print(login_key, login_value)
    for field, value in login_value.items():
        print(field, value)
  • Yes, I just practice .. Now I will try to set the value of each key in each uzer :) Thank you – Horrible27 Oct 4 '16 at 19:36