Which of the following is the correct way to create a list in Python?
- list = "1, 2, 3, 4"
- list = (1, 2, 3, 4)
- list = [1, 2, 3, 4]
- list = {1, 2, 3, 4}
The correct way to create a list in Python is by using square brackets, as shown in "list = [1, 2, 3, 4]". Square brackets denote a list in Python.
Loading...
Related Quiz
- The ____ method in Pandas is used to drop specified labels from rows or columns.
- In a Python codebase, you see that a child class is trying to modify an attribute with two leading underscores from a parent class but encounters an error. What's the likely cause?
- How does Python enforce the private access modifier for class members?
- In the pytest framework, how do you mark a test function so that it is not executed by the test runner?
- In a for loop, what does the range(3, 8, 2) function return?