How to Create a Tuple with Only One Item in Python


In this example, we will learn how to create a tuple with only one item in Python.

Source Code

my_tuple = ('a',)    # you have to add a comma after the item

print(type(my_tuple))

Output:

<class 'tuple'>
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
Advertisement