What's the difference between list and tuples?
Answer / Chandan Kumar
The main difference between lists and tuples is that lists are mutable, meaning you can change their contents, while tuples are immutable, meaning their contents cannot be changed. Here's an example:
```python
my_list = [1, 2, 3]
my_tuple = (1, 2, 3)
my_list[0] = 'a'
print(my_list)
# Output: ['a', 2, 3]
my_tuple[0] = 'a'
# This will raise a TypeError: 'tuple' object does not support item assignment
```
| Is This Answer Correct ? | 0 Yes | 0 No |
What is a CGI script in Python?
What is the input function in python?
where can I get the study material for python
Give an example of shuffle() method?
What is the Global Interpreter Lock (GIL) in Python?
What is cgi in python?
What type of a language is python? Interpreted or Compiled?
How do you comment in python?
What is the difference between python append () and extend () functions?
Is it worth to learn python in 2019?
What are its benefits of flask?
Is using eval in python a bad practice?