8. Lists
8.1. Before Kattis
Write a function
find_in_list(element, a_list) -> bool:The function will
returnTrueifelementexists within the lista_listandFalseotherwiseThis can use either a
forloop or awhileloop
Write a function
index_of(element, a_list) -> int:The function will
returnthe index of the first occurrence ofelementwithin the lista_listand-1if it is not foundThis can use either a
forloop or awhileloop
Write a function
replace_all(the_list, find, replace):This function will replace all occurrences of
findwithinthe_listand replace them withreplaceThis function must
returnthe modified listFor example,
replace_all([1, 2, 2, 3], 2, 9)->[1, 9, 9, 3]
Use the
replace_allfunction to change the list[1, 2, 2, 1]->[2, 1, 1, 2]You will need to use
replace_allmultiple times