I need to write a function that converts an integer into binary. The function definition I have written so far is:
def decimalToBinary(number):
if number > 1:
decimalToBinary(number//2)
print(number % 2, end = '')
My problem is that:
- I should return the result instead of printing it, and I am unsure how to do that.
- I am overall unsure if my code is the best recursive code I could have written.
Thank you for your time!