Recently, I had problems creating a program that is calculated in binary format from 1 to the selected number.
This is my code at the moment:
num6 = 1
binStr = ''
num5 = input('Please enter a number to be counted to:')
while num5 != num6:
binStr = str(num6 % 2) + binStr
num6 //= 2
num6 = num6 + 1
print(binStr)
For example, if I enter 5, he needs to go 1, 10, 11, 100, 101. It seems that I just do not understand. Any help would be appreciated, thanks.
source
share