Syntax error in a beast program in Python

Asked

Viewed 100 times

-1

modo = int(input("Selecionar modo de jogo: "))

if modo == 1
print("deu 1")

if modo == 2
print("deu 2")

I just wanted to test if the user, when typing 2 the program prints 2 and the same pro 1, but ta giving syntax error, algm ajuda me

    1. Indentation, it is required in Python. Code blocks inside the if must be indented relative to it; 2) Missing two dots, :, at the end of all if;

1 answer

2


From what I’m seeing your code has a number of errors:

  1. Identation: when you use one if, the next line must contain 4 spaces in relation to the top line.
  2. When calling the function if and its conditions, there must be the two-point sign (:) then for python to be able to assimilate that it is a block of code.
  3. This last error is not in relation to the code but rather to your question, have you read the article on how to ask a good question in stackoverflow? I suggest you take a look and fix it there :).

Regarding your problem, this is the code you are looking for:

modo = int(input("Selecionar modo de jogo: "))

if modo == 1:
    print("deu 1")

if modo == 2:
    print("deu 2")
  • I didn’t read it, I did it kind of rushing because I would need it for tomorrow, but I’m going to take a look at some classes, thank you.

  • @Kah, if the answer was satisfactory to your problem, please mark it as accepted,! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.