-1
How can I display the conversion results only after the negative number is typed? Currently, it reads and already displays. I wish he could read and only after typing a negative number, he would display the results
def converte(numBinario, base):
numBinario = str(numBinario)
numDecimal = (int(numBinario, 2))
if numDecimal != 0:
numConvertido = ""
while numDecimal > 0:
resto = numDecimal % base
numConvertido = str(resto) + numConvertido
numDecimal = numDecimal // base
else:
numConvertido = "0"
return numConvertido
n = int(input())
while n != -1:
for bases in range(3, 10 + 1):
convertido = converte(n, bases)
print()
n = int(input())
print(convertido, end=" ")
If I understood you will have to save in a list and then print the list. Anyway it seems to have other errors in the code.
– Maniero
The way the code is currently running and displaying values, only that it reads and displays, I wish it could read and only after I type the -1 it displays, and I don’t know how to implement this list
– MSSantana