FreeKB - Append values to the end of an array in Python
Append values to the end of an array in Python

Home > Search
  by

The append operator can be used to append values to the end of an array in Python. For example, let's say you have an array of fruit.

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

 

In this example, kiwi is appeneded to the end of the array.

fruits.append('kiwi')

 

You can loop through the array.

for x in fruits:
  print(x)

 

Kiwi will be included at the end of the array.

apple
banana
orange
grapes
kiwi


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