If grammar is correct, but invaind syntax appears.

Asked 1 years ago, Updated 1 years ago, 351 views

I was just playing with Python, but when I tried to branch y/n using the if statement, I got an invite syntax.

When I looked up the error online, it said that I forgot to attach a full-width space or colon, but I didn't feel like I saw such a grammatical error.

What should I do?

code:

check=input("y/n");
if check == "y";
 print(num+nnuumm)
else;

I don't know how to display the code in the stackoverflow for the first time, but please forgive me.

The error line is

if check=="y";

That's it.

python

2022-10-13 01:01

1 Answers

The if statement ends with : instead of ; (semi-colon).( else as well)

example description:

if conditional expression:


2022-10-13 01:01

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.