Question

Would python have a problem dealing with my re-use of item in various for-in loops???

list1 = (A,B,C,D)
list2 = (E,F,G,H)

for item in list1:
    (eg) ...item+5
    (eg) ...item*1

for item in list2:
    (eg) ...item+2
    (eg) ...item*3
Was it helpful?

Solution

Python does not have a problem with re-using names in for loops.

item will get rebound for each and every iteration, you can safely reuse it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top