Write Function Called Modifythirdelem Takes Two Arguments List Least Length 3 Element Inse Q43804683
Write a function called modify_third_elem that takes twoarguments, a list that is at least of length 3, and an element thatwill be inserted into the 3rd index of the list. The functionshould return the modified list.
The answer I got that works in the program is:
some_list = [‘1’, ‘2’, ‘3’, ‘4’, ‘5’]
some_list2 = ‘honey’
def modify_third_elem(some_list, some_list2):
some_list[3] = some_list2
return some_list
print(modify_third_elem(some_list, some_list2))
and the error that came up in the program is:
F
======================================================================
FAIL: test (test_methods.Test)
———————————————————————-
Traceback (most recent call last):
File “/usr/src/app/test_methods.py”, line 23, in test
self.assertEqual(lst2, main.modify_third_elem(lst1, elem1))
AssertionError: Lists differ: [1, 2, 5, 4, 5] != [1, 2, 3, 5,5]
First differing element 2:
5
3
– [1, 2, 5, 4, 5]
? —
+ [1, 2, 3, 5, 5]
? +++
———————————————————————-
Ran 1 test in 0.000s
FAILED (failures=1)
Expert Answer
Answer to Write a function called modify_third_elem that takes two arguments, a list that is at least of length 3, and an element …
OR