I want to implement a function that takes a tuple
of int
s and increases the last element by 1:
inc((0,0,0,1))==(0,0,0,2)
inc((1,2,3))==(1,2,4)
This is what I came up with:
def inc(t):
l=list(t)
l[-1]+=1
return tuple(l)
Can this be done in a more compact way (and maybe without the conversion to list) ?