Panhary H.

asked • 02/27/23

Write a function larger_decrement(numlist, n) that takes two parameters, a list of integers numlist, and an integer n.

Documentation: 

Use the following template for EVERY function that you write. The docstring below should be placed inside of the function, just after the function signature.

'''

Purpose:

Parameter(s):

Return Value:

'''


If the given list contains any number larger than n, then have the function mutate the list by decreasing the largest item in the list by 1. If the list has two or more elements tied for the largest, only decrease the first occurrence. Then the function should return True. 


If the given list does not contain any number larger than n, it should return False.


Examples (text in bold is returned):


>>> alist = [5, 20, 74, 81, 0, 81, 3]

>>> larger_decrement(alist, 50)

True



1 Expert Answer

By:

Tantoh H. answered • 02/28/23

Tutor
New to Wyzant

I am an online and and a community Tutor for over 3 years

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.