White Hat – Python Foundations
beginner20 XP

Lists & User Input

Store collections of data in lists and get information from the user

Lists & User Input

What is a List?

Python
fruits = ["apple", "banana", "mango"]
scores = [95, 87, 72, 100]

Accessing Items

Python
print(fruits[0])   # apple (index starts at 0!)
print(fruits[-1])  # mango (last item)

Useful Methods

Python
fruits.append("mango")   # add to end
fruits.remove("apple")  # remove item
print(len(fruits))       # number of items

User Input

Python
name = input("What is your name? ")
age = int(input("How old are you? "))
print("In 10 years you will be", age + 10)
⌨️

Type it yourself

Don't just read it — type the example from above into the box, press Run ▶, and watch what happens. Typing it yourself is how it really sticks! Stuck? Tap Show example.

Python · Playground
Output
Press ▶ Run to see your code come to life…

Quick check

01/3

What index gets the FIRST item in a list?