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..

Recommended Answers

All 2 Replies

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

My bad. Thank you for your help...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.