6 ms·
Yeah.. It also used to work with def, but it was removed in python3. You can do this in 2.7: def func((a,b)): return b mytuple = 1,2 print func(my
by justinsaccount 10y ago
Yeah.. It also used to work with def, but it was removed in python3. You can do this in 2.7:
def func((a,b)):
return b
mytuple = 1,2
print func(mytuple)
in py3 you need
def func(t):
a,b = t
return b
Not sure if
This is probably the cleaner way to write that:
key=operator.itemgetter(1)