Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in python Write a function larger_decrement(numlist, n ) that takes two parameters, a list of integers numlist, and an integer n. If the given list
in python
Write a function larger_decrement(numlist, n ) that takes two parameters, a list of integers numlist, and an integer n. 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. Hints: - The autograder will be expecting you to return a boolean value, make sure that you use the specific values True and False Constraints: - You are not permitted to use built-in functions like max( or sorted() that trivialize the task of finding the largest element in the list. You are welcome to add an if __name _ == ' _main__' block and test cases for this and all functions in this assignment but this is not required. Examples (text in bold is returned): > alist =[5,20,74,81,0,81,3] > larger_decrement(alist, 50) True > alist [5,20,74,80,0,81,3] > blist =[1,3,5] > larger_decrement(blist, 6) False >> blist [1,3,5]Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started