Reputation: 129
ok guys I wrote this script and the logic seems fine also syntax but when i try to execute this script itll ONLY execute the if not the else or elif??? I'm so confused please help me??? please try it and see what I mean???
import math
def main():
usr = input('''Please select which task you would like to do?:
plese TYPE either "Sphere Area" or "Sphere Volume"''')
if (usr == "Sphere Area" or "sphere area"):
sphereArea()
elif (usr == "Sphere Volume" or "sphere volume"):
sphereVolume()
else:
print("Please try again wrong choices:")
return main()
def sphereArea():
r = eval(input("Please input the radius: "))
sa = float(4 * 3.14 *(r)**3)
print(sa)
def sphereVolume():
a,b,c = eval(input("Please input the Values for A,B,C in the order, please include comas::"))
sv = float(4/3 * 3.14 * a*b*c)
print("The Volume of the sphere is :",sv,"m3")
main()
Upvotes: 0
Views: 31
Reputation: 81
If always evaluates to true because: You have usr == "Sphere Area" or "sphere area"
In this, "sphere area"
will always be true.
You should write: usr == "Sphere Area" or usr == "sphere area"
Upvotes: 1