Creating Heterogeneous Tuples

Write a Python program to create a tuple with different data types. Return the tuple.

Example 1:

Input: 5, 'hello', 8.3 
Output: (5, 'hello', 8.3)

Example 2:

Input: 7, 'world', 3.14, 'd' 
Output: (7, 'world', 3.14, 'd')

In Python, a tuple can be created by placing all the items (elements) inside parentheses (), separated by commas.

def create_tuple(*args):
    return tuple(args)

© Let’s Data Science

LOGIN

Unlock AI & Data Science treasures. Log in!