Feb-25-2022, 05:44 AM
(This post was last modified: Feb-25-2022, 05:44 AM by deanhystad.)
Be consistent with your indentation (always use 4 spaces). Inconsistent indenting makes your code hard to read.
An exception takes you out of the while loop.
Your program needs to do this:
An exception takes you out of the while loop.
try: while flag == False: item1 = input("Enter a value: ") item1 = int(item1) # If an exception happens here the program jumps down to line 8 list1.append(item1) num = num + 1 # This is the last command in the while loop. except Exception: if len(item1) == 0: # The program jumps here if an exception occurs. This is not in the while loop. print("This one")You don't know Python and you are letting that affect how you write programs. Coding in a particular language is a small part of the programming task. Most of programming is coming up with a good algorithm for solving the problem. You need to focus on the algorithm first, then think about translating the algorithm to Python.
Your program needs to do this:
repeat get user input if input is not empty convert input to a number and add it to a list until input is empty if list is not empty print max value of list print min value of list do other things involving the listHow can you convert that to Python?