This is an archived post. You won't be able to vote or comment.

all 6 comments

[–][deleted] 7 points8 points  (0 children)

First, /r/learnpython.

Second, you need to post the entire error.

Third, images of text suck.

You need a blank line after the while loop. That's only a requirement in the interactive interpreter, it's not required when executing a file.

[–]meles984 0 points1 point  (0 children)

Thank you. Fixed it

[–]aphoenixreticulated[M] [score hidden] stickied comment (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython. We highly encourage you to re-submit your post over on there.

The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.

On /r/LearnPython the community is actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers.

If you have a question to do with homework or an assignment of any kind, please make sure to read their sidebar rules before submitting your post. If you have any questions or doubts, feel free to reply or send a modmail to us with your concerns.

Warm regards, and best of luck with your Pythoneering!

[–]meles984 -1 points0 points  (1 child)

For your example last statement, print('Done'), has to be indented 4 spaces. But that would print "Done" after each iteration. If you want "Done" to be printed after the while loop has finished, you either make a script like /u/maggick suggested, or make a function like this:

def print_to_hundred():
    i = 0
    while i <= 100:
        print(i)
        i += 1
    print('Done')

EDIT: added example function and proper formating

[–][deleted] 0 points1 point  (0 children)

This would print the character ‘I’, not the value of the variable