dimanche 25 juin 2017

if statement follows through even though arguments are not met

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://ift.tt/PWWhNu 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?

Aucun commentaire:

Enregistrer un commentaire