I am doing a all round calculator for my first main project and i have fell into a small hiccup. There is a part of code that i want to repeat, but don't know how to. To make it more clear, i have a section called inequalities, and i want the user to be able to choose if he wants to stay in inequalities or go back to the start. I am not sure if there is a code that works like a checkpoint that you can make your code go back to. I've tried to find a code that would work like that but had no luck. Any others suggestions would be appreciated. The code:
import math
while True:
print("1.Add")
print("2.Subtract")
print("3.Multiply")
print("4.Divide")
print('5.Exponent')
print('6.Square Root (solid numbers only)')
print('7.Inequalities')
choice = input("Enter choice(1/2/3/4/5/6/7): ")
if choice in ('1', '2', '3', '4'):
x = float(input("What is x: "))
y = float(input('What is y: '))
if choice == '1':
print(x + y)
elif choice == '2':
print(x - y)
elif choice == '3':
print(x * y)
elif choice == '4':
print(x / y)
if choice in ('5'):
x = float(input('Number: '))
y = float(input('raised by: '))
if choice == '5':
print(x**y)
if choice in ('6'):
x = int(input('Number: '))
if choice == '6':
print(math.sqrt(x))
if choice in ('7'):
print('1.For >')
print('2.For <')
print('3.For ≥')
print('4.For ≤')
pick = input('Enter Choice(1/2/3/4): ')
if pick in ('1', '2', '3', '4'):
x = float(input("What is on the left of the equation: "))
y = float(input('What is on the right of the equation: '))
if pick == '1':
if x > y:
print('true')
else:
print('false')
elif pick == '2':
if x < y:
print('true')
else:
print('false')
elif pick == '3':
if x >= y:
print('true')
else:
print('false')
elif pick == '4':
if x <= y:
print('true')
else:
print('false')
back = input('Do you wanna continue with intequalities: ')
if back in ('YES', 'Yes', 'yes', 'no', 'No', 'NO'):
if back == 'YES' or 'Yes' or 'yes':
print('ok')
#the print('ok') is there for test reasons, and i want to replace it with the peice of code that will allow me to return to line 33