Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
if statement not working
#1
Hi,
I'm trying to make a python game called Math God, which has three subjects:
1. Quadratics
2. Interest
3. Order of Ops.

I'm trying to make an if statement inside the try statement, but I keep getting a bad input error.

Here's my code.


#Math God
#By Trenton
#Made in 2018
#You answer questions correctly in under a minute. Each correct answer is worth 50 points. Get one wrong and you get a strike. Three strikes and the game ends. There are three subjects: quadratics, interest, and order of ops. Each contain 50 questions selected at random within that subject.
input("Math God				 Press any key to start")
print("Welcome to Math God! Made by Trent in 2018!")
print("In this game, you have a minute to answer the math problem correctly. If you get it wrong or run out of time, you get a strike. Three strikes and the game is over.")
try:
  x=input("There are three modes to this game: quadratic, interest, and order of operations. Type 'q' for quadratics, 'i' for interest, and 'o' for order of ops.")
if x = 'p':
  input("You have selected quadratics. Press any key to start."
else 
    if x = 'i':
        input("You have selected interest. Press any key to start.")
    else 
        if x = 'o':
          input("You have selected order of operations. Press any key to start.")
  except:
  input("Sorry, but you didn't correctly choose a valid mode. Press any key to continue.")
return
If you could tell me what I'm doing wrong, that would be great
Reply


Messages In This Thread
if statement not working - by trent101010 - Mar-08-2018, 07:14 PM
RE: if statement not working - by wavic - Mar-08-2018, 07:48 PM
RE: if statement not working - by sparkz_alot - Mar-08-2018, 08:19 PM
RE: if statement not working - by trent101010 - Mar-08-2018, 10:52 PM
RE: if statement not working - by trent101010 - Mar-11-2018, 05:02 PM
RE: if statement not working - by wavic - Mar-11-2018, 07:07 PM
RE: if statement not working - by trent101010 - Mar-12-2018, 06:17 PM
RE: if statement not working - by Larz60+ - Mar-11-2018, 08:53 PM
RE: if statement not working - by wavic - Mar-14-2018, 03:19 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
Question If, elif, and else statement not working PickleScripts 3 902 Mar-30-2023, 02:53 PM
Last Post: PickleScripts
  If statement not working correctly? MrKnd94 2 843 Nov-16-2022, 02:49 AM
Last Post: deanhystad
  If Statement not working...Why? Milfredo 2 2,216 Oct-17-2020, 03:23 AM
Last Post: Milfredo
  Invoking function in if else statement, not working! ibaad1406 13 5,663 May-30-2019, 09:05 PM
Last Post: ibaad1406
  If statement not working oldcity 4 3,112 Oct-14-2018, 10:45 AM
Last Post: oldcity
  why is this try.....except statement not working? HenryJ 3 8,772 Feb-06-2018, 06:15 AM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020