r/learningpython • • Jan 18 '26

Confused about why code A doesn't work

This is in a while loop called is_bidding

Code A:

resume = input("Is there another bidder? Type 'yes' or 'no': \n").lower()
    print(resume)
    if resume != 'no' or 'yes:
        print('We will take that as a no')
        is_bidding = False        
    elif resume == 'yes':
        print("Let us resume.")
    else:
        print("Very well let's see whose won...")
        is_bidding = False

intentions: I wanted the if statement to check if the user did NOT enter 'yes' or 'no'

results: When typing 'yes', the first condition runs, and I am not sure why

Edit: Thanks for the feedback, I understand what I did wrong.

2 Upvotes

12 comments sorted by

View all comments

1

u/Outside_Complaint755 Jan 19 '26 edited Jan 19 '26

As others have said, instead of 

if resume != 'no' or 'yes`:

 You need to do (edited)

if resume != 'no' and resume != 'yes`:

or

if resume not in ('no', 'yes'):

1

u/Major-Language-2787 Jan 19 '26

OOOOOOOOH, it makes all the sense now. I need to remember that

1

u/FredOfMBOX Jan 19 '26

Needs to be an and, not an or.

1

u/Outside_Complaint755 Jan 19 '26

Good catch, fixed.