Question: Code not working because of break is outside loop. . list1=[] def handle_add(): print(Enter the integers one by one or type done to finish: )

Code not working because of break is outside loop.

.

list1=[]

def handle_add():

print("Enter the integers one by one or type done to finish: ")

while(True):

c=input()

if(c=="done"):

raise Exception ("say it done")

else:

list1.append(int(c))

def handle_print():

s=0

while(True):

print ("type sum to add all numbers, type average to find mean, min to find min number and max to find max number")

print("type done to return back to main menu")

d=input()

if(d=="done"):

raise Exception ("say it done")

elif(d=="sum"):

for i in list1:

s=s+int(i)

print("sum :"+str(s))

elif(d=="average"):

for i in list1:

s=s+int(i)

s=s/len(list1)

print("Minimum :"+str(min(list1)))

elif(d=="min"):

print("Minimum :"+str(min(list1)))

elif(d=="min"):

print("Maximum :"+str(max(list1)))

else:

print("I don't know what that is.")

if _name=="main_":

while(True):

print("type add to add data, print to display data and exit to close the program: ")

ch=input()

if (ch=="exit"):

raise Exception ("exit")

elif(ch=="add"):

handle_add()

elif(ch=="print"):

if(len(list1)==0):

print("Not available. Please enter data first.")

continue

handle_print()

else:

print("Unknown command")

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!