0

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!

2
Contributors
5
Replies
6
Views
6 Years
Discussion Span
Last Post by JoshuaBurleson
0

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?

0

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 by JoshuaBurleson: n/a

1

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 topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.