13. For your lists


#1

Can someone explain to me why the first piece of code works fine but the second piece of code code doesn't.

#code 1
numbers  = [7, 9, 12, 54, 99]

print "This list contains: "

for num in numbers:
    print num

# Add your loop below!
for num in numbers:
    print num ** 2

#code 2
numbers  = [7, 9, 12, 54, 99]

print "This list contains: "

for num in numbers:
    print num

# Add your loop below!
for num in numbers:
   num ** 2
   print num

#2

you multiply, but don't save this multiplication anywhere


#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.