ash15khngI think this code would work:
print(f"Bin: {str(bin(int(input('Dec to bin: '))))[2:]}")
Explanation:
input() gets the number
int() turns it into an integer
bin() turns it into a binary integer
str() turns it into a string
[2:] removes the "0b" in front of it
The entire thing is in an "f string" which just makes it easier to format
And print() is to output the final string
Hope this helped!5 years ago
TheDrone7Try to convert it into Binary first, then binary number to string and use the lstrip method on the string.5 years ago
pyeliasDid your friends use some variant of bin(num).lstrip("- 0b")? The difference between that and what you did is that that lstrips the binary string, while you are lstriping the number itself, instead of a string.5 years ago