Robotics & Artificial Intelligence

What is the difference between list and tuple in Python? Explain with the help of an example.

Getting Started

2 Likes

Answer

ListTuple
Elements of list are enclosed within square brackets [ ].Elements of tuple are enclosed within parentheses ( ).
List is mutable (elements can be changed).Tuple is immutable (elements cannot be changed).
Example: my_list = [1, 1.0+3j, "great", True]Example: my_tuple = (1, 2, 3, 4)

Answered By

3 Likes


Related Questions