dimanche 24 octobre 2021

how to sort a list in a while loop

I want to write a program which reads numbers from the user, until the user enters "0"

and then the program returns the lowest number in that string. I am having trouble sorting out the string.

This is my code so far:

    while True:
    number = []
    number = input("Please enter a number ")

    if number == "0":
        break

number.sort()
x = number[0]
return x

Aucun commentaire:

Enregistrer un commentaire