Hello, I am trying to create a number exponentiator in python. I have already succeeded in writing it using only integer numbers, but I am trying to write an updated, better version where you can also input floats as the base or the exponentiator. Unfortunately, the function i have written to do this task always seems to return None, no matter what I try. I’d really like some help as to how I can prevent this.
None could mean that no return keyword is reached, so None
is the absence of a return value. Which is the case here
all your conditions evaluate to false.
there are several problems: input()
will gives us a string. So you would need to convert to integer or float first
number1 == int
will never be true. Lets say number1
has a value of 3, the comparison still would be false:
3 == int
3 is of type int, so you would need to check if type
of number1
is an integer.
I appreciate the feedback you’ve given me. I was wondering if you could provide me with the syntax required to fix the issues you’ve highlighted in my code.
I could, but what do you learn from that?
we could start with a simple search on google: python get type
which gives me:
https://www.geeksforgeeks.org/type-isinstance-python/
so you could use this to check the data type of inputs.
This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.