0

why is an empty dictionary output in the first case?

https://code.sololearn.com/cA76lNFAXhTp/?ref=app

7th Feb 2023, 2:05 AM
Andrew The Python Slayer
Andrew The Python Slayer - avatar
2 Respostas
+ 5
If you comment out your first print statement (line 4) then it will work. The reason is that the zip function creates an iterator (something like a loop that does not yet materialize the values). In your line 4, you consume this iterator by converting it to a list. So there is nothing left for the dictionary in line 5.
7th Feb 2023, 3:56 AM
Tibor Santa
Tibor Santa - avatar
+ 1
I deleted the fourth line and understood everything thanks
7th Feb 2023, 7:30 AM
Andrew The Python Slayer
Andrew The Python Slayer - avatar