Creating a list is a fundamental operation in Python programming. In this blog post, we’ll explore different code examples that demonstrate how to create a list efficiently.
Example 1:
fruits = ['apple', 'banana', 'orange', 'kiwi'] print(fruits)
Output: [‘apple’, ‘banana’, ‘orange’, ‘kiwi’]
Example 2:
numbers = list(range(1, 6)) print(numbers)
Output: [1, 2, 3, 4, 5]