Which of the following statements is used to create a list in Python?
Correct answer
C. list = [1, 2, 3]
16 views
C. list = [1, 2, 3]
16 views
list = [1, 2, 3] creates a list — square brackets define lists in Python.
Curly braces {1, 2, 3} create a set, parentheses (1, 2, 3) a tuple, and quotes a string. (In real code avoid naming a variable list, because that hides the built-in type.)
Practise more Computer Science MCQs with answers and explanations on MCQsExam.com.
Not sure why the answer is C? Ask here and get an explanation.