Python Python Basics All Together Now Cleaner Code Through Refactoring

So a user can currently put anything in the confirm purchase except N or n. How to change?

Currently when confirming as long as the user does not put N/n in as input, the program confirms the order.

How would I and where would I add code that says it needs to be Y/y/YES/yes. or even something like if not Yes or no related it makes the user try again?

1 Answer

54,333 Points

I'm not seeing the same thing you are. In the video's workspace the confirmation checks for "y" or "Y" (by converting the variable storing the input to lowercase) on line 23:

if should_proceed.lower() == "y":

If you also wanted to include various combinations of case for "yes" you could add

if should_proceed.lower() == "y" or should_proceed.lower() == "yes":

Can you provide a link/time for the video showing the code checking for N/n?