What is the difference between list and tuples in python?



What is the difference between list and tuples in python?..

Answer / Hansraj Meena

In Python, lists are mutable, meaning you can change their contents, while tuples are immutable, meaning once they are created, you cannot modify them. To create a list, use square brackets [ ], and to create a tuple, use parentheses ( ). Here is an example: nn```pythonnmy_list = [1, 2, 3]nmy_tuple = (4, 5, 6)nmy_list[0] = 'a' # valid for listsnmy_tuple[0] = 'a' # generates an error

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Python Interview Questions

How can I evaluate an arbitrary python expression from c?

1 Answers  


where can I get the study material for python

1 Answers  


Can I use python to make a website?

1 Answers  


What are “special” methods in python?

1 Answers  


Is python is easy?

1 Answers  


Explain help() and dir() functions in python?

1 Answers  


Does python have a built in function for string natural sort?

1 Answers  


What are the built-in type does python provides?

1 Answers  


What are decorators in python and how do you use them?

1 Answers  


What is the language from which Python has got its features or derived its features?

1 Answers  


What is the necessity to use pass statement in python program?

1 Answers  


Explain how to delete a file in Python?

1 Answers  


Categories