What's wrong?


#1



https://www.codecademy.com/courses/python-beginner-en-cxMGf/0/3?curriculum_id=4f89dab3d788890003000096#

while num in range(1,11):
print num**2

The output is:
100
100
100
100
100
100
100
100


I expected to print from 1 to 10 squared as the assignment requested.


Replace this line with your code.


#2

why do you use a while loop here? To get through values in range, use a for loop


#3

Instead of while, you need for.


#4

I know. But the assignment challenges me with while loop. I am stuck


#5

By the way, my new codes are:

num = 1
while (num < 11):
    print num**2
    num = num + 1

#6

this code works fine :slight_smile: Maybe refresh the page


#7

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