lists and for loops

Emily Anne Moravec moravec at stolaf.edu
Wed Aug 17 23:08:23 EDT 2011


I want to add 5 to each element of a list by using a for loop.

Why doesn't this work?

numbers = [1, 2, 3, 4, 5]
for n in numbers:
     n = n + 5
print numbers





More information about the Python-list mailing list