[Solved] Python 2 – Print in every loop, all time that my loop works, I want to print it


You need to learn basic I/O in Python and how loops work.

If you just want to spit out the score, you need a print statement to do that. I see you also have an “if (score < 500)` in there, you can get rid of it and do that if check in the loop.

With the print statement and the loop altered you get this (corrected since posting for Python 2 syntax):

score = 1
while score < 500:
    print score
    score += 50

Once score is over 499, the loop will end and the program will just ‘exit’.

You should also consider reading up more on the basics of Python, such as through the Python 2 tutorial/introduction documentation by the Python developers. It explains how to do while loops and print statements so you can see the value of a specific variable and such. (I would advise that you look into Python 3, however, as Python 2 will be dead within two years’ time and not supported by upstream anymore, so Python 3 is the new ‘standard’ Python that you should probably get used to; it’s not too different from Python 2, but it’s different enough to need some effort to switch some things over to it)

1

solved Python 2 – Print in every loop, all time that my loop works, I want to print it