I cant seem to figure this out. I need to write a while loop to output the numbers from 1 to 10, but no matter what I put it will not run. Here is what I have been stuck on:

a = 0
while a < 10 :
a += 1
print (a)

I dont understand why this does not work. I have found the exact formula on the same problem on other websites, all with the output numbers from 1 to 10 just like what I am looking for, but nothing works!

Please help!

Im running Python 2.7.2

Thank you!

Is your indentation correct?

a=0
while a<10:
        a+=1
        print(a)

i believe so. whats the quantity of indentations? like, 3 spaces, 2 tabs? etc?

I believe the google standard is four spaces, I use one tab. It's VERY important, whitespace realllly matters in python, I suggest the one tab method, it's quicker and cleaner in my opinion.

Here was my output:

>>> 
1
2
3
4
5
6
7
8
9
10
>>>

Edited 5 Years Ago by pyguy62: n/a

I believe the google standard is four spaces, I use one tab. It's VERY important, whitespace realllly matters in python, I suggest the one tab method, it's quicker and cleaner in my opinion.

Here was my output:

>>> 
1
2
3
4
5
6
7
8
9
10
>>>

Thank you so much! Im not sure what it was, but I restarted my computer and reopened the GUI and used the indentations that you told me and it worked like a charm.

Thank you so much! I really appreciate this. Now I just need to learn the rest of this stuff :P

This article has been dead for over six months. Start a new discussion instead.