- 2
Change the code to print binary equivalent of base ten numbers. Work in progress. I am also working on it
The code prints the binary equivalent of number input. https://code.sololearn.com/cqO4Mz7JJ6ci/?ref=app
5 Respostas
+ 2
You set n to 0 then had a while loop that only executes while n is greater than 0. So that code will never run as written.
+ 1
Hi Martin!
Here it is corrected code
n = int(input())
b = ""
while (n>0):
r = n%2
b += str(r)
n=n//2
print(b[::-1])
+ 1
Martin Raj Kumar Well, there's a much simpler way to do this:
print(bin(num)[2:])
0
Short n sweet ❤❤
- 2
Now you can find it. 😁