0
Good afternoon, I am doing a job for the college on conversion, I have this code below and I wanted to use a break in it so when the user type a number q not be the '1' or '0' he of a msg and return so that the user type right, more not getting, can help me out ?
vet = []
soma = 0
potencia = 3
for i in range(4):
ver = int(input('Digite UM numero entre 0 e 1: '))
if ver => 2:
print('Digite corretamente')
break
else:
vet.append(ver)
soma = soma + (vet[i] * (2 ** potencia))
potencia = potencia - 1
print('Codigo binario convertido em decimal é: ', binDec())
what is the error? apparently the code is ok
– rLinhares
when it passes to Else, it gets an infinite loop, rather than calling input only 4 times as requested !
– Anderson Santana
There are syntax errors in your code that prevent you from testing the reported problem:
if ver => 2
, the operator=>
does not exist in Python (maybe wanted to use>=
) and the functionbinDec
used in the last line is not defined.– Woss