Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

list help 4.3.3 Coding Exercise 1 (External resource) (3.0 points possible) Modify.py Submit Run Grades Reset #write a tunction calledmodity-list. modity-list will 2ttake one parameter

image text in transcribedlist help

4.3.3 Coding Exercise 1 (External resource) (3.0 points possible) Modify.py Submit Run Grades Reset #write a tunction calledmodity-list. modity-list will 2ttake one parameter a list. It should then modify the , ' 3#list in the following ways, in this order: 4 #-sort the list (using the default sort method) Ens te defa iethod). method) 5# -Reverse the order of the list 6#-Delete the last three items of the list 6 # . Delete theel asa rof the list. 7#-Remove s one instance the integer?from the list, if 8# it's present 9 -Double the values of the first and third items in 10# the list. 11 #It should then return the resulting list. You may assume 12#the list will start with at least six items 13 #Hint: Remember Python is 0-indexed. The second item 14 #does not have an index of 2.?int 2: Remember, the list. remove() function removes items 15#by value, not by index. Note also that if the item you're 16#trying to remove is not found in the list, remove() will 17 #throw an error : so, you'll want to avoid that one way or 18 #another! 19 #krite your code here: 20 #Below are some lines of code that will test your function 21 #You can change the value of the variable(s) to test your 22#function with different inputs 23 #If your function works correctly, this will originally #print: 24 #1178, 81, 75.0, 4, 3.141592653589793, 3] 25 import moth 26 print (modify list(l7, 4, 3, 2.0, 81, 37.5, 89, math.pi, -2, math.el)) Console output will be displayed here

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions