I will get a number for the output of this piece of code:
base = int(raw_input("Pick your base: "))
base = str(base)
question = "Pick your number! (the base is "+base+" ): "
number = int(raw_input(question))
def func(number):
if number != 0:
sec = number/int(base)
third = number - (sec * int(base))
print third,
func(sec)
func(number)
I want to take the output (for example 2435) and reverse it (to 5342). I have tried the a[::-1] by assigning the func(number) to a variable and then printing that variable[::-1] however this does not seem to work:
x = func(number)
print x[::-1]
That gives me:
TypeError: 'NoneType' object has no attribute 'getitem'
Your method
funcis missing areturnstatement (and thus returnsNone). Without returning a value, you can't apply the index operator on it.