Question
Python. if you can give an example that would be great. Basically, I need help with making it so the user has to type y
Python. if you can give an example that would be great. Basically, I need help with making it so the user has to type y or n nothing else to continue or quit a program.
You have a long list of code and it performs a calculation. You ask the user at the end of the program another_calculation=input('Do you want to perform another calculation?(y/n):')
if (another_calculation_!='y')
do_calculation= False
The code runs
Do you want to perform another calculation ?(y/n):
The problem is you can type anything that is not a y to kill the program
How do you make it so that the user has to type y or n and if the user does not type n to quit the program it will keep repeating until the user types n or y. like I don't want the user typing in o instead of n to quit program?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started