Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a function called modify_third_elem that takes two arguments, a list that is at least of length 3, and an element that will be inserted

Write a function called modify_third_elem that takes two arguments, a list that is at least of length 3, and an element that will be inserted into the 3rd index of the list. The function should 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)

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_2

Step: 3

blur-text-image_3

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

Students also viewed these Databases questions

Question

Describe the factors influencing of performance appraisal.

Answered: 1 week ago

Question

What is quality of work life ?

Answered: 1 week ago