samedi 2 janvier 2021

Is There A Reason Why This if statement Isn't Working In This Class Inheritance? [duplicate]

So I am learning about inheritance in classes in python, and I decided to play with a bit of conditional to see what it gives me. I stumbled onto something that didn't entirely make sense to me and my curiosity has yet to be satisfied even with google searches. I am a total newbie and would love to get some understanding on this. Thanks.

Context:

I created a Motorcycle class and defined a method called TankSize. I noticed the 'if' statement always evaluated to true and thus printed the resulting block/clause no matter what i type in the input function. Even zero. I am curious why that is the case.

code:

class Motorcycle(object): def init(self, seats, psgrs): self.seats = seats self.psgrs = psgrs # psgrs = passengers

def TankSize(self):
    print('What is the tank size: Large or Normal?')
    input('N for normal, L for large')
    if input() == 'large' or 'Large' or 'LARGE' or 'l' or 'L':    # here is where the problem is.
        print('large Tank Size')     # always prints this even when i type the wrong inputs
    else:
        print('Normal Tank Size')

Mitsubishi = Motorcycle('2 seats', '1 passenger')

Aucun commentaire:

Enregistrer un commentaire