>>> while True: print(count)
... count+=1
File "<stdin>", line 2
count+=1
^^^^^
SyntaxError: invalid syntax
I'm trying to do the loops exercise on the learnpython.org website and the problem i ran into is how to use the ":" correctly
>>> while True: print(count)
... count+=1
File "<stdin>", line 2
count+=1
^^^^^
SyntaxError: invalid syntax
I'm trying to do the loops exercise on the learnpython.org website and the problem i ran into is how to use the ":" correctly
I see you are at this lesson : https://www.learnpython.org/en/Loops
One of the major point of Python is that indentation is syntaxically significant
https://www.learnpython.org/en/Hello%2C_World%21
Indentation
Python uses indentation for blocks, instead of curly braces. Both tabs and spaces are supported, but the standard indentation requires standard Python code to use four spaces.
This code block will work
while True:
print(count)
count+=1
Python likes its blocks. At the beginning do not try to put all statements in one line.