Python (Scripting) - Getting Started with Lists
by
Jeremy Canfield |
Updated: November 06 2023
| Python (Scripting) articles
This is an empty list that contains no values.
fruits = []
This is an list that contains values.
fruits = ["apple", "banana", "orange", "grapes"]
You can print the list. This will display the entire list.
print(fruits)
Which should return the following.
['apple', 'banana', 'orange', 'grapes']
You can print a certain value in the list. This will print "apple".
print(fruits[0])
You can loop through the list.
for x in fruits:
print(x)
This will print each fruit.
apple
banana
orange
grapes
Did you find this article helpful?
If so, consider buying me a coffee over at