I just started with Python,
Is there some iteration in dictionary like in PHP
foreach(aData as key=>value)
It looks like something like this :
my_dict = {"key1": 1, "key2":2}
my_dict.items() # in python < 3 , you should use iteritems()
>>> ("key1", 1), ("key2", 2)
so you can iterate on it :
for key, value in my_dict.items():
do_the_stuff(key, value)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With