Bootstrap FreeKB - Python (Scripting) - Getting Started with Lists
Python (Scripting) - Getting Started with Lists

Updated:   |  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 Buy Me A Coffee



Comments


Add a Comment


Please enter 26679e in the box below so that we can be sure you are a human.