+ 2
Use of items() and dictionares in python
I'm learning how to use dictionaries and the method items() when I have this code: dic = {"1": 100, "2": 200}; for x in dic.items(): print(x); The ouput will be ('1', 100) ('2', 200) but if I use: for x, y in dic.items(): print(x, y); The ouput will be: 1 100 2 200 why in the first code, the output is with the quotation mark, and the second code, there is no quotation mark? What is the difference? and which one is better to use?
1 Respuesta
+ 2
Puny Programmer Thx!