I am still learning the fundamentals of Python, but I am getting stuck on this custom calculator program I am attempting to finish.
while True:
print('Welcome. Below, type the number associated to begin calculating:')
print('1: Addition')
print('2: Subtraction')
print('3: Multiplication')
print('4: Division')
pick = int(input('Enter the number associated with your calculation: '))
if pick != (1, 5):
print('Please enter an option given.')
else:
continue
def addNumber():
if pick == 1:
print('-------------------------')
print('You have chosen #1 - Addition.')
num1 = int(input('Enter your first number: '))
num2 = int(input('Enter your second number: '))
print('Your sum is equal to:', num1 + num2)
print('-------------------------')
addNumber()
The first function is addition, and the rest of the functions are its own for each choice. This next part is the bottom, allowing the user to restart if chosen.
again = str(input('Would you like to calculate again?\n'))
if again == 'Yes':
continue
else:
break
There is no issue if the user tries to put a value outside of the range of 1-4 (prompting to try again), but if someone picks a shown option (like they're supposed to), 'Please enter an option given.'
shows up.
Welcome. Below, type the number associated to begin calculating:
1: Addition
2: Subtraction
3: Multiplication
4: Division
Enter the number associated with your calculation: 1
Please enter an option given.
You have chosen #1 - Addition.
Enter your first number:
How should I rewrite that if/else parameter?