Beginner Codes/Python/Iterables
44%

Instructions

Syntax

for item in iterable: print(item)

What are Iterables? 🔄

Python-la 'Iterable' nu sonna, adhu oru collection of items. Andha collection-la irukka ovvoru item-ayum namba oru for loop vachu thani thaniya edukkalam.

Types of Iterables 📚

Namba idhuvaraikum neraya iterables-a paathurukkom:

  1. Lists [1, 2, 3]
  2. Strings "HELLO"
  3. Tuples (10, 20)
  4. Sets {1, 2, 3}

Ivaigal ellame iterables dhaan! Idhula irukka items-a namba conveyor belt-la anuppura madhiri loop panni paakalam.

# Looping through a List
fruits = ["Apple", "Banana", "Cherry"]
for fruit in fruits:
    print(fruit)

# Looping through a String
word = "PYTHON"
for letter in word:
    print(letter)

The Conveyor Belt 🏭

Oru iterable-a for loop-la pota enna aagum nu kizhe ulla diagram-la paarunga. List and String rendu option-um check panni paarunga!

Iterables Conveyor Belt

# Define the iterable
fruits = ["Apple", "Banana", "Cherry"]
for item in fruits:
print(item)
Terminal
print(item)
"Apple"
"Banana"
"Cherry"
Lists are iterables. The loop takes one item at a time from index 0 to the end.

Your Turn! (Unga neram!)

  1. Oru string name = "CODE" nu create pannunga.
  2. Adha oru for loop vachu iterate pannunga.
  3. Loop kulla print(item) nu type panni output-a check pannunga!

Help

IterablesExercise 35/7735 XP
❴❵ script.py
python.code
python
Loading...
Terminal
Terminal — python
Beginner Codes Terminal v1.0.0
─────────────────────────────────────
Ready. Click "Run Code" to execute...
Ready
Piston APIPYTHON0 lines