I am writing a recursive function that will print the result of converting a base 10 integer to its equivalent in another base. At line 11 I receive:
TypeError: not all arguments converted during string formatting
Can anyone see what I am doing wrong here and how should I fix it?
list = []
def con2base(integer, base):
if integer == 0:
if list == []:
list.insert(0, 0)
return 0
else:
return 0
while integer > 0:
list.insert(0, (integer % base)) <----- This is the offending line
return con2base(integer / base, base)
print ("Enter number to be converted: ")
integer = raw_input()
print ("Enter base for conversion: ")
base = raw_input()
con2base(integer, base)
print list