Python Programming - Variables - Discussion

Discussion Forum : Variables - General Questions (Q.No. 28)
28.
Which of the following is NOT a valid way to declare a tuple?
my_tuple = 1, 2, 3
my_tuple = (1, 2, 3)
my_tuple = tuple(1, 2, 3)
All of the above are valid
Answer: Option
Explanation:

my_tuple = tuple(1, 2, 3) is not a valid way to declare a tuple in Python.

Instead, you can use my_tuple = 1, 2, 3 or my_tuple = (1, 2, 3) to create a tuple directly, or use the tuple() function to convert another iterable (like a list) into a tuple.

For example: my_tuple = tuple([1, 2, 3])

Discussion:
Be the first person to comment on this question !

Post your comments here:

Your comments will be displayed after verification.