Sum of digits of 0303 is 15 - Why?


#1

Hi guys.
I have some question about this code. It works properly but if I try to pass over an argument that equals (0303) the function returns "15". Does anybody know why it is happening? ))


Digit_sum question
#2

The leading 0 in 0303 indicates to the Python interpreter that it is to be evaluated as an octal (base 8) number. Expressed as a decimal number, it is 195. The sum of the digits of 195 is 15. Tricky, but very interesting.


#3

Thanks a lot for your explanation. I didn't have it on my mind )


#4