please code in python def duplicate(nums,a): """ MODIFIES thelist so that all occurrences of a are duplicated This function should have NO RETURN STATEMENT Examples: If a = [1,2,3,1] then a becomes [1,1,2,3,1,1] after duplicate(a,1). If a = [1,2,3,1] then a remains [1,2,3,1] after duplicate(a,4). Parameter nums: list to modify Precondition: nums is a list of ints Parameter a: value to search for Precondition: a is an int """ # IMPLEMENT A WHILE LOOP HERE # END WHILE LOOP pass
please code in python
def duplicate(nums,a):
"""
MODIFIES thelist so that all occurrences of a are duplicated
This function should have NO RETURN STATEMENT
Examples: If a = [1,2,3,1] then a becomes [1,1,2,3,1,1] after duplicate(a,1).
If a = [1,2,3,1] then a remains [1,2,3,1] after duplicate(a,4).
Parameter nums: list to modify
Precondition: nums is a list of ints
Parameter a: value to search for
Precondition: a is an int
"""
# IMPLEMENT A WHILE LOOP HERE
# END WHILE LOOP
pass
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images
it gives me the following error, please help me fix it
Testing duplicate assert_equals: expected [5, 3, 3, 3455, 74, 74, 74, 74, 74, 74, 3, 3] but instead got [5, 3, 3, 3455, 74, 74, 74, 74, 74, 3, 3] Line 43 of /Users/fmolukanmi/Documents/cs1110/lab22/tests.py: introcs.assert_equals([5, 3, 3, 3455, 74, 74, 74, 74, 74, 74, 3, 3], mylist) Quitting with Error