1
I would like to know a way to accept only the entry with 1 digit. In the case below: 1, 2 or 3.
Entries of type 0001, 01, 0002. (with zero left) was not valid (presented an error) and returned to type again a number between 1 and 3.
Can someone help me?
def choice_game_to_play():
playing = False
try_login = 0
print("*****************************************")
print("*************CHOICE A GAME!**************")
print("*****************************************\n")
while not playing:
try:
try_login += 1
playing = try_login == 6
print("(1) Roll dice - (2) Guess a number - (3) Jokenpo\n")
game = int(input("Choice a game between 1 and 3: "))
if game <= 0 or game > 3:
print("\n**********Invalid value, try again!**********\n")
else:
if game == 1:
play_dice()
elif game == 2:
play_guessing()
elif game == 3:
play_jokenpo()
except ValueError:
print("\n*************Invalid value, try again!*************\n")
continue
Try:
game = input("Choice a game between 1 and 3: ")
while (game not in ["1", "2", "3"]):
 print("\n**********Invalid value, try again!**********\n")
 game = input("Choice a game between 1 and 3: ")
game = int(game)

.– anonimo
Hummm, I understand the logic! I will implement. Thanks
– Camila Cavalcante
I wanted to understand why this question had negative votes. Could anyone who gave negative votes talk about?
– jsbueno
This has been happening a lot. The questions are clear, well structured. However, it seems that if the person does not understand, or does not know how to answer, vote negative.
– Rebeca Nonato