Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
755 B
2
Indexable
Never
list_of_numbers = []
total = 0
lowest = None
highest = None

while True:
    try:
        line = input("Enter number or press Enter to finish: ")
        if not line:
            break
        number = int(line)
        list_of_numbers.append(number)
        total += number
        if lowest is None or lowest > number:
            lowest = number
        if highest is None or highest < number:
            highest = number
    except ValueError as err:
        print(err)

        print("Number: ", list_of_numbers)
        if list_of_numbers:
            print("count: ", len(list_of_numbers),
                  "sum= ", total, "lowest= ", lowest, "highest= ", highest,
                  "mean= ", total / len(list_of_numbers))