Early programming

Asked

Viewed 35 times

-2

Make a program that shows on the screen a multiple choice question, and that, from the user’s answer, show on the screen whether he hit or not.

Unable to develop this question, my code became like this:

print("Exercício 02: ")
print("O maior rio em extensão territorial é o rio Nilo ?")

resposta = str(input("Se for verdadeiro escrava sim"))

if resposta != sim:
    print("você acertou!")
else:
    print('Você errou!')

But the program cannot compile

1 answer

-1


Your program is not running because on your parole you are comparing response to sim, where yes should be a string using quotes.

Corrected

print("Exercício 02: ")
print("O maior rio em extensão territorial é o rio Nilo ?")

resposta = str(input("Se for verdadeiro escrava sim"))

if resposta != "sim":
    print("você acertou!")
else:
    print("Você errou!")
  • Thanks for the help.

Browser other questions tagged

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