+ 1

Recursion Decimal to binary

How can i make this code right to convert decimal to binary. NB: Without changing the third line! https://code.sololearn.com/cr0Haqu5ePUF/?ref=app

7th Aug 2021, 7:52 AM
sid
sid - avatar
1 Réponse
+ 10
You're just missing the base case. def convert(num): if num>=1: return (num % 2 + 10 * convert(num // 2)) return num print(convert(int(input())))
7th Aug 2021, 8:00 AM
Hatsy Rei
Hatsy Rei - avatar