python example

Python list basics

Create a list, append, slice, and loop. A beginner Python list tutorial you can run online.

Lists keep an ordered collection. append adds to the end; slicing returns a new list without changing the original.

Read Output after each print. Then add one more fruit and Run again.

fruits = ["apple", "banana", "cherry"]
fruits.append("date")

print(fruits)
print(fruits[0])
print(fruits[1:3])

for fruit in fruits:
    print(fruit.upper())