What would be the easiest (shortest) way to switch elements in tuple?
my_tuple= (a,b)
After switch:
new_tuple= (b,a)
What would be the easiest (shortest) way to switch elements in tuple?
my_tuple= (a,b)
After switch:
new_tuple= (b,a)
By reversing it:
>>> my_tuple = ('a', 'b')
>>> new_tuple = my_tuple[::-1]
>>> new_tuple
('b', 'a')
In [32]: my_tuple= ('a','b')
In [33]: tuple(reversed(my_tuple))
Out[33]: ('b', 'a')