You want to make a list in Python to store data.
Which statement is the correct way to accomplish this task?
In Python, to create a list, you use square brackets []. The correct syntax to create a list containing the numbers 0 through 5 is:
L = [0, 1, 2, 3, 4, 5]
This statement creates a list object that stores the specified integers.
Other options are incorrect:
A defines a string, not a list.
B defines a set, which is an unordered collection with no duplicate elements.
D defines a tuple, which is an immutable sequence, not a list.
Python Official Documentation: Discusses lists, sets, tuples, and their syntaxes.
Python Data Structures Guide: Provides examples of creating and manipulating lists.
Currently there are no comments in this discussion, be the first to comment!