KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

Write a program that inputs two tuples and creates a third one that contains all the elements of the first tuple followed by all the elements of the second tuple.

Python Control Flow

1 Like

Answer

tuple1 = eval(input("Enter first tuple: "))
tuple2 = eval(input("Enter second tuple: "))
tuple3 = tuple1 + tuple2
print("First tuple:", tuple1)
print("Second tuple:", tuple2)
print("Combined tuple:", tuple3)

Output

Enter first tuple: (1, 2, 3)
Enter second tuple: (4, 5, 6)
First tuple: (1, 2, 3)
Second tuple: (4, 5, 6)
Combined tuple: (1, 2, 3, 4, 5, 6)

Answered By

3 Likes


Related Questions