dimanche 28 novembre 2021

I have a program that just does not work & I need to find the bug

my task is to write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the number. When I run my program it does not repeatedly ask for number, it just does it one time without responding.

`

    try:
        float(num)
    except:
        "invalid input"

    if num > largest:
        largest = num
    
    if smallest == 0:
        smallest= num
    
    if smallest > num:
        smallest = num
    print(num)

`

Aucun commentaire:

Enregistrer un commentaire