✦ Osnove Pythona Kolekcije

Concept 06 · Lists

Keep related values
zajedno po redosledu.

Lists let Python keep several values in one ordered, changeable collection.

01 Uči02 Isprobaj03 Predvidi

Lista čuva više vrednosti u određenom redosledu.

Write values between square brackets and separate them with commas. Each value has a position, so Python can find or change it later.

fruits = ["apple", "banana", "orange"]
print(fruits)

The name fruits refers to one list containing three strings in order.

['apple', 'banana', 'orange']

Lists are mutable: you can replace an item without creating a new list. len() tells you how many items the list contains.

↳

Zapamtite: List positions use indexes that begin at 0, not 1.

Promenite jednu stavku
fruits = ["apple", "banana", "orange"]
fruits[1] = "pear"
print(fruits)

Index 1 is the second item, so only "banana" changes to "pear".

Python radni prostor

Učitavanje Python okruženja…

Change an item or add another fruit, then run the code in your browser.

lists.pyPython
IzlazČeka se Python
Okruženje pregledača se učitava. I dalje možeš da menjaš primer koda.

Pyodide pokreće Python u Web Worker-u pregledača. Zaustavlja se i ponovo pokreće ako se kod predugo izvršava. Izvršavanje u pregledaču nije potpuna bezbednosna granica; ne unosi tajne i ne oslanjaj se na njega za izolaciju nepouzdanog koda.

Šta će ovaj program ispisati?

Follow the index that is changed before print() runs.

colors = ["red", "blue", "green"]
colors[0] = "yellow"

print(colors)
Izaberi izlaz
Sloby, maskota Python AI Tutora

Tvoj mentor za učenje

Ask Sloby about lists

Describe what feels unclear about list order, indexes, or changing items.

Zdravo! Ja sam Sloby. Hajde da zajedno istražimo Python liste.

What will this program print, and why? Explain which list item changes.

numbers = [10, 20, 30]
numbers[1] = 50

print(numbers)
Python AI Tutor · Uči razumevanjem, a ne samo pokretanjem koda.