0
def list_function(x):
    x[1] = x[1] + 3
    return x[1]
n = [3, 5, 7]
print list_function(n)

It shows following error when i run the code for multiple times.
1. Oops, try again. list_function([6, 3]) returned 6 instead of [6, 6]
2.Oops, try again. list_function([1, 6]) returned 9 instead of [1, 9]
3.Oops, try again. list_function([2, 5]) returned 8 instead of [2, 8]
and so on..

2
Contributors
2
Replies
15
Views
1 Year
Discussion Span
Last Post by ray.shahil95
2

You are not asking the function to return the set, you are asking the function to return the second element of the set. (return x[1])

If you want the set returned, simply return x

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.