Question: Python help: I am very confused on what to do. It needs to be a while loop but i have no clue how to go
Python help: I am very confused on what to do. It needs to be a while loop but i have no clue how to go about this! All the info is below!
Write a function called addmax(list, threshold) that adds up as many elements as possible from a list starting from the first item with sum less than a given threshold.(hint: use while loop)
For example,
print addmax([2,3,5,7],6) will get 5
print addmax([2,3,5,7],11) will get 10#because 2+3+5=10< 112+3+5+7=17>11
define your function below:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
