0
how to make choices in python?
for example you want to code a calculator of + and multiply when you open the calculator it must ask you what do you want to calculate + or ×
2 Antworten
+ 9
a=2
b=3
answer=input("enter + or * \n")
if answer == "+":
print(a+b)
elif answer == "*":
print(a*b)
else:
print("invalid")
+ 1
if, elif and else statements