“Wie füge ich Einschränkungen in Eingaben in Python hinzu” Code-Antworten

Wie füge ich Einschränkungen in Eingaben in Python hinzu

while True:    
    try:
        hp_cur=int(input("Enter the current number of HP (1-75): "))
    except ValueError: # used to check whether the input is an int
        print("please insert a int type number!")
    else: # is accessed if the input is a int
        if hp_cur < 1 or hp_cur > 75:
            print("please insert a number in the given limit")
        else: # if number is in limit, break the loop
            break  
Venatus

Wie füge ich Einschränkungen in Eingaben in Python hinzu

hp_cur=int(input("Enter the current number of HP (1-75): "))
hp_max= int(input("Enter the maximum number of HP (1-75): "))
hp_dif=(hp_max-hp_cur)
Venatus

Ähnliche Antworten wie “Wie füge ich Einschränkungen in Eingaben in Python hinzu”

Fragen ähnlich wie “Wie füge ich Einschränkungen in Eingaben in Python hinzu”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen