In this python tuple program, we will swap the tuples.
Steps to solve the program
- Take two tuples as input.
- Swap the tuples by using the ” = ” operator i.e. a,b=b,a.
- Print the output.
A=(7,4,9)
B=(3,)
print(f"tuple1: {A}, tuple2: {B}")
A,B = B,A
print(f"tuple1: {A}, tuple2: {B}")
Output :
tuple1: (7, 4, 9), tuple2: (3,)
tuple1: (3,), tuple2: (7, 4, 9)