In Python ” else SyntaxError: expected ‘:’ ” error occurs when we miss a colon (:) at the end else statement. In Python, after the if-else statement end line code, we need to add a colon, colons are used to indicate the start of a new block of code, such as the body of a for loop or an if and else statement. In our code, we need to just add a colon (:) after else and then run the code again, for more clarification please see the below example.
Wrong Code
print("Welcome to the Amol Blog payground hall")
height = int(input("What is your height in cm:"))
if height >120:
print("You can come the cinema hall")
else
print("Sorry, you have to grow taller befor you play")
Error Massage
File "/home/kali/python/webproject/error/main.py", line 6
else
^
SyntaxError: expected ':'
Wrong code line
else
Correct code line
else:
- Wrong action: no colon (else).
- Correct action: add a colon (else:).
Entire Correct Code line
print("Welcome to the Amol Blog payground hall")
height = int(input("What is your height in cm:"))
if height >120:
print("You can come the cinema hall")
else:
print("Sorry, you have to grow taller befor you play")
What is else SyntaxError: expected ‘:’?
In python, we face this error because of forgetting to include a colon (:) at the end of the else statement line then we are facing this error. In Python, colons are used to indicate the start of a new block of code, such as the body of a for loop or an if else statement.
How to fix else SyntaxError: expected ‘:’?
In python, if we want to fix this error, we need to make sure that you add a colon(:) at the end of every else statement line. for more clarification please see the below example.
For more information Visit YouTube Channel.

