How to create a tuple in Python?

In Python, there are two ways to create a tuple.

  1. Separate the elements with commas and enclose them in parentheses.
my_tuple = (1, 2, 3)
  1. create an empty tuple.
my_list = [1, 2, 3]
my_tuple = tuple(my_list)

It is important to note that tuples are immutable and cannot be changed once they are created.

bannerAds