Jun-18-2024, 05:57 PM
I have spent way to much time on this. What I need to do, make a math tutor. I have this entire thing figured out but this.
What it needs to do, if a zero is input, I need it to read an error and then loop ONLY to the division...not back to the main menu.
Please tell me there is someone who can help. I have tried so many things for the last three days and my eyes are going cross.
This currently will ask for first and second number, then show the error....but then asks for answer (which is obviously going to work)...then it shows the error. If a zero is input in the first two numbers, then an error needs to show, then loop back to ask for the numbers again until no zeros are input. Then it continues with the program.
**be kind, this is my first post in any group...and this is my first programing class ever.**
What it needs to do, if a zero is input, I need it to read an error and then loop ONLY to the division...not back to the main menu.
Please tell me there is someone who can help. I have tried so many things for the last three days and my eyes are going cross.
#division calculation elif choice == divF: try: num1 = int(input("Enter first number: ")) num2 = int(input("Enter second number: ")) c_answer = (num1 / num2) except ZeroDivisionError: print("Cannot use a zero in division, please try again") answer = float(input("Enter answer:")) #output if c_answer == answer: print("Correct, great job!") else: print(f'Incorrect, the answer is {c_answer:.2f} .')
This currently will ask for first and second number, then show the error....but then asks for answer (which is obviously going to work)...then it shows the error. If a zero is input in the first two numbers, then an error needs to show, then loop back to ask for the numbers again until no zeros are input. Then it continues with the program.
**be kind, this is my first post in any group...and this is my first programing class ever.**