i wrote a simple recursive script to change decimal to hexadecimal, but it returns the answer in tuple, its not a big deal, i get what i want, but i would like to understand why i get a tuple, anyone could explain it?
this is the script:
def printDigits(n,base):
if n < base:
return n
else:
return printDigits(n//base, base) , n % base
and for
print(printDigits(245, 16))
i get
(15, 5)
>Solution :
The return in the else statement of printDigits contains a comma, which is how you define a tuple in Python.
return printDigits(n//base, base) , n % base