Answer the question
In order to leave comments, you need to log in
How to check each digit in a number for compliance, and if the condition is true, then a certain sentence is displayed?
getNumber = input('Введите число: ') # Ввод числа
x = 1
y = 0
var2 = getNumber[:1]
v = len(getNumber)
for i in range(v+1):
if var2 == '1' or var2 == '0':
var2 = getNumber[y:x]
x += 1
y += 1
print("верно")
else:
print('Двоичное число может содержать только цифры 0 и 1')
break
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question