Just started learning DS&A on my own recently and in the Recursion part of the book, it lists the code below as a basic example of Recursion being used to convert an integer into a string:
def to_str(n,base):
convert_string = "0123456789ABCDEF"
if n < base:
return convert_string[n]
else:
return to_str(n/base,base) + convert_string[n%base]
When I call the function and print using print(to_str(1453,10)), I get the error: TypeError: string indices must be integers.
What am I doing wrong?