The question is:
Based on the image I attached, I would like to know why the conditional I have created inside the loop in the second loop assigns None to the dictionary variable? It should do it right but I can't find the answer.
I have tried to search the Python documentation but I can't find anything, if someone can clarify this question for me I would appreciate it !!
What you print is the result of the iteration at the beginning, before setting the "total" key. If you put the print at the end of the loop you will see that it is set correctly. In the first iteration, the variable "i" does not contain "with" so the key is created but set to None. The loop is wrong because in the first iteration you set "net" with the value you want and "total" with None, but in the second iteration, you are going to set "net" with None and "total" with the value you want. You can try something like: