# These lines print out the question, possible answers and a prompt for the user to input
a string
print("ART AND LITERATURE: Who painted Starry Night?")
print("a. Vincent Van Gogh")
print("b. Michelangelo")
print("c. Leonardo Da Vinci")
answer = print(input("Enter your choice:"))
# Semantic error: prints out 'a' and 'The correct answer was a' when input is 'a'
# Desired output: "Correct!" when input is 'a' and 'The correct answer was a' for other
inputs
if answer == 'a':
print("Correct!")
else:
print("The correct answer was a")
The first block of code prints out the question, possible answers, and a prompt for the user to input a string.
The if-else statement has a semantic error as it prints out "a" and "The correct answer was a" even when the input is indeed, "a".
How do I fix this so that "Correct!" is printed when the input is 'a' and 'The correct answer was a' for other inputs?
Aucun commentaire:
Enregistrer un commentaire