Question: We want to make a program that, when given a list, will sort through all the values of the list and take only the numerical
We want to make a program that, when given a list, will sort through all the values of the list and take only the numerical values until it encounters the word "done". Then it will return the total sum of these values, the average value, and a count of the number of numerical values in the list. Each list will be string list, so it can contain values such as "Microsoft" or "hello", and every list will contain the word "done" to indicate when your program should stop running.
For example, if we had the list ['hello', '5', 'world', 5, 'done', '12'], it would return an output such as "Total is: 10.0. Average is: 5.0. Count is: 2." since there are only two numbers that it encounters before it reaches the word "done". Note that the number 12 is skipped because the program finds the word 'done' before it reaches 12.
In [3]: from loopwrapper import * In [6]: #Takes in string list (generated from user input) and returns the sum and mean until it encounters "done" string. def loop_til_done(lst): return False In [ ]: run (loop_til_done) Please enter a seed of the form 'seed [number]' or a numerical value: 1 Please type in a number, or 'done': 1 Please type in a number, or 'done': done
Step by Step Solution
There are 3 Steps involved in it
Python function that accomplishes this task python def looptildonelst total 00 co... View full answer
Get step-by-step solutions from verified subject matter experts
