82.9k views
3 votes
PROBLEM 3 This program is about exception handling. Create an empty list. Use a loop to ask user to input 5 integers. In every iteration, add user input to the list if it can be converted to an integer. Otherwise, display an error message. Display the list of integers after the loop. The following is an example: Enter an integer: 24 Enter an integer: 5.6 Input value cannot be converted to integer Enter an integer: 1,000 Input value cannot be converted to integer Enter an integer: 41 Enter an integer: 8 Integer list: [24, 41, 8] Save your Python program in a file named Lab11P3.py. Submit the file to Blackboard for credit.

1 Answer

7 votes

Answer:

see explaination

Step-by-step explanation:

The program code

lst = []

for i in range(5):

n = input("Enter an integer: ")

if(n.isdecimal()):

lst.append(int(n))

else:

print("Input value cannot be converted to integer")

print("Integer list:",lst)

see attachment for output

PROBLEM 3 This program is about exception handling. Create an empty list. Use a loop-example-1
User Allevo
by
4.2k points