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)

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
>>>

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

Great, glad to help. Upvote as you see fit and mark the thread solved.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.