Arrays in Python

Home > Search
  by

This is an empty array that contains no values.

fruits = []

 

This is an array that contains values.

fruits = ["apple", "banana", "orange", "grapes"]

 

You can print the array. This will display the entire array.

print fruits

 

You can print a certain value in the array. This will print "apple".

print fruits[0]

 

You can loop through the array.

for x in fruits:
  print(x)

 

This will print each fruit.

apple
banana
orange
grapes

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




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




Comments