0

So im following through with these projects upon being recommended them as a beginner. Im stuck on the third project where I am trying to fulfill the subtasks too:

def PythagTripCheck():
    sidesCount=0
    smallSideDone=False
    mediumSideDone=False
    largeSideDone=False
    while sidesCount<3:
        whatSide=input("What side would you like to enter first? 'Small', 'Medium' or 'Large'?")
        if whatSide=="Small" or "small" or "S" or "s" and smallSideDone==False:
            smallSide=input("Enter the length of the small side:")
            if smallSide.isdigit() == False:
                print("The small side contains a character which is not a number, your numbers have been reset, try again")
                PythagTripCheck()
            else:
                sidesCount=sidesCount+1
                smallSideDone=True
        elif whatSide=="Medium" or "medium" or "M" or "m" and mediumSideDone==False:
            mediumSide=input("Enter the length of the medium side:")
            if mediumSide.isdigit() == False:
                print("The medium side contains a character which is not a number, your numbers have been reset, try again")
                PythagTripCheck()
            else:
                sidesCount=sidesCount+1
                mediumSideDone=True
        elif whatSide=="Large" or "large" or "L" or "l"and largeSideDone==False:
            largeSide=input("Enter the length of the large side")
            if largeSide.isdigit() == False:
                print("The large side contains a character which is not a number, your numbers have been reset, try again")
                PythagTripCheck()
            else:
                sidesCount=sidesCount+1
                largeSideDone=True
        else:
            print("Please try again")



PythagTripCheck()

The code runs the small side no matter what. whatSide DOES change to a different value from the initial value, and [side]SideDone does change to True when the corresponding side is followed through when a second (different) attempt is tried. But,

if whatSide=="Small" or "small" or "S" or "s" and smallSideDone==False:
        smallSide=input("Enter the length of the small side:")
        if smallSide.isdigit() == False:
            print("The small side contains a character which is not a number, your numbers have been reset, try again")
            PythagTripCheck()
        else:
            sidesCount=sidesCount+1
            smallSideDone=True

Always goes through, and I have no idea why. I tried http://www.pythontutor.com/ and It even says that the values of whatSide are not equal to any of the parameters for the small side.

What am I doing wrong?

  • So if i were to get rid of the "Sorry" or "sorry" or "S" or "s" it may work? Ill test it. –  Jun 25 '17 at 18:50
  • The equals sign does not distribute – OneCricketeer Jun 25 '17 at 18:51
  • Yooooo it worked I love you @JJJ can you comment it so i can give you the best answer? –  Jun 25 '17 at 18:51
  • You don't need to get rid of them; just write the conditions out in full (`if whatSide=="Small" or whatSide=="small" or ...`). Just click on the "this solved my question" button (or whatever it says). – JJJ Jun 25 '17 at 18:52
  • Yeah I figured that out too, thanks :D –  Jun 25 '17 at 19:34

0 Answers0