+ 1
How do i implement a function that takes in 3 parameters' tuple index and a value and change the value at the index to a new val
4 Respostas
+ 2
My version would have been this:
def change_tup(tup, idx, val):
return tup[:idx]+(val,)+tup[idx+1:]
+ 2
Yeah, when you use just parentheses for a single value, Python will just dissolve them, like in (1+2)*3.