Skip to content
Quiz Coding
Profile icon
KeshavNair

I am making code for a quiz. In the quiz, I want to make sure that when a user selects a certain answer, the program would display "true" or "false". How would I make this happen

You are viewing a single comment. View All
Profile icon
PYer

Define a variable called answer that gets the user's selected answer using the input() function. Then create an if statement checking what the user entered, and then printing "True" or "False".
Example:

print("What is Bill Gate's net worth?") answer = input("(USD): ") if answer.lower() == "9.7 billion": print("True") else: print("False")