0

Design a program with a loop that lets the user enter a series of numbers. The user should enter - 99 to signal the end of the series. After all the numbers have been enter been entered, the program should display the largest and smallest numbers entered.

when I go to run my program and enter a number like "4" it returns saying the smallest and largest number is 4. But when I want to put a series of numbers like "3,4,5" it gives an error. I don't know if I am typing it wrong or if there is an issue with my program. Let me know what you guys think

def main():
displayWelcome()
inputNum = int(); smallest = int(); largest = int()
smallest = None
largest = None
SENTINEL = -99
# program description

while True:
    inputNum=int(input('Enter a number (Zero indicates end of input): '))

    if inputNum == SENTINEL:
        print('End of program')
        break
    if smallest is None or inputNum < smallest:
        smallest = inputNum
    if largest is None or inputNum > largest:
        largest = inputNum
        
    displayLargestSmallest(largest, smallest)

def displayWelcome():
print ('This program displays the largest and smallest numbers \
entered by the user from a series of numbers')

def displayLargestSmallest(largest, smallest):

    #module to display numbers input
    print('The largest number input is ', largest)
    print('The smallest number input is', smallest)
  • 5
    is this an assignment? – MEdwin Oct 08 '21 at 22:55
  • 1
    The variable inputNum will hold only one value per iteration so if you want to input a series of numbers input the values as a list. This might help you: https://stackoverflow.com/questions/4663306/get-a-list-of-numbers-as-input-from-the-user – Tharu Oct 08 '21 at 22:59

1 Answers1

0

You are complicating things, now you will receive a set of numbers in an array, and you will extract the largest number, its number, and the smallest number and print it as follows: enter image description here