#π why do i keep getting none when im doing 3 number Division?
13 messages Β· Page 1 of 1 (latest)
@violet oyster
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
enter=input("enter what do u want")
how =int(input("how many numbers"))
calc=["+","-","x","/"]
def sum(num1,nu2,num3):
if how ==2:
return num1+nu2
else:
return num1+nu2+num3
def sub(num1,nu2,num3):
if how==2:
return num1-nu2
else:
return num1-nu2-num3
def multi(num1,nu2,num3):
if how==2:
return num1 * nu2
else:
return num1*nu2*num3
def ap(num1,nu2,num3):
if how ==2:
return num1/nu2
else:
num1 / nu2 / num3
num1= float(input("enter"))
nu2=float(input("enter"))
if how==3:
num3 = float(input("enter"))
elif how==2 and enter==(calc[0]):
num3=int(0)
elif how==2 and enter==(calc[1]):
num3=int(0)
elif how==2 and enter== (calc[2]):
num3=int(1)
elif how==2 and enter==(calc[3]):
num3=float(1)
if enter==(calc[0]):
print(sum(num1,nu2,num3))
elif enter==(calc[1]):
print(sub(num1,nu2,num3))
elif enter==(calc[2]):
print(multi(num1,nu2,num3))
elif enter==(calc[3]):
print(ap(num1,nu2,num3))
else:
print("fail")
@pastel creek mind helping?
in your ap function, did you forget a return on the else?
bro...
i cant be this stupid
π
thanks!
its fine
ive been coding for years and still spend 30+ minutes debugging code to realize i didnt call a function or something
πmakes me feel better i quit coding few years ago and just got back to it was doing c++ before so I thought python had something weird spent 1 hour tryna figure it out myself then i asked here
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.