0
When I do this code outside a function it works, now when I do with function it returns me 0.
``` def validacao(x): try: x = int(input()) band = 1 except ValueError: band = 0 while band==0: print("Somente números!") try: x = int(input()) band = 1 except ValueError: band = 0 print("1 - Inserir registro de um cliente") print("2 - Listar os registros dos Bebes") print("3 - Buscar pelo registro de um Bebe") op = 0 validacao(op) ```
This code is very confusing and makes no sense: https://answall.com/q/456654/101 and https://answall.com/a/428367/101 and https://answall.com/a/433051/101 and https://pt.stacklowoverf.com/a/433468/101 and https://en.stackoverflow.com/q/451936/101
– Maniero
The function
validacao
does not have a return? And please review the indentation of your code in the question. Currently there is awhile band == 0
that would generate endless "Numbers only" messages and crash your program.– Woss
About while, it has an input below after Try, to validate once again, it doesn’t keep generating endless messages. When I do this validation without being inside gave a function it works. Thank you
– Victor Hugo
@Victorhugo, I don’t know if it was a mistake to copy here but it seems your code has an indentation problem. The Try and excpet should be inside the while, otherwise the code makes no sense.
– Flavio Moraes