w3resource logo
Python Exercises

Python Exercise: Create a tuple with numbers, and display a member

Python tuple: Exercise-3 with Solution

Write a Python program to create a tuple with numbers and print one item.

Sample Solution:-

Python Code:

>>> #Create a tuple with numbers
>>> tuplex = 5, 10, 15, 20, 25
>>> print(tuplex)
>>> #Create a tuple of one item
>>> tuplex = 5,
>>> print(tuplex)

Sample Output:

(5, 10, 15, 20, 25)                                                                                           
(5,) 

Python Code Editor:

#Create a tuple with numbers
tuplex = 5, 10, 15, 20, 25
print(tuplex)
#Create a tuple of one item
tuplex = 5,
print(tuplex)

Improve this sample solution and post your code through Disqus