somehow, when i pick the option "sqrt" it does works but shows the second "else" too... how can i fix it?
#Trying to build a calculator
import math
n1=float(input('Pick a number:'))
opr=str(input('+, -, *, /, **, sqrt?'))
if opr == 'sqrt':
s=math.sqrt(n1)
print(f'The square root of {n1} is {s}')
else:
n2=float(input('Another one:'))
if opr == '+':
s=n1+n2
print(f'The sum of {n1} and {n2} is equal to {s}')
elif opr == '-':
s=n1-n2
print(f'The subtraction between {n1} and {n2} is equal to {s}')
elif opr == '*':
s=n1*n2
print(f'The product between {n1} and {n2} is equal to {s}')
elif opr == '/':
s=n1/n2
print(f'The division between {n1} and {n2} is equal to {s}')
elif opr == '**':
s=n1**n2
print(f'{n1} to the power of {n2} is equal to {s}')
else:
print('Are you dumb? Please pick a valid operation/number!')
if i run (number) then sqrt, it shows:
Pick a number:
55
+, -, *, /, **, sqrt?
sqrt
The square root of 55.0 is 7.416198487095663 (first else)
Are you dumb? Please pick a valid operation/number (second else)