Beginner Codes/Python/2D Collections
29%

Instructions

Syntax

pad[row][col]

2D Collections (List of Lists) 🔲

Namba lists pathi padichom. Aana oru list-kulla inoru list irundha? Adhu dhaan 2D Collection (illana 2D List).

Idha purinjikka oru phone keypad-a imagine pannikonga. Adhula Rows (addasama) and Columns (neduvasama) irukkum.

1. Creating a 2D List 🛠️

pad = [
    [1, 2, 3], # Row 0
    [4, 5, 6], # Row 1
    [7, 8, 9]  # Row 2
]

2. Accessing Items 🎯

Ippo indha keypad-la irundhu namba 6 a edukhanum na eppadi eduppom?

  1. Mudhalla, 6 endha Row-la irukku nu paakanum. Adhu Row 1-la irukku.
  2. Apram, andha Row-la 6 endha Column-la irukku? Column 2-la irukku.

So namba pad[row][column] nu kodukkanum:

print(pad[1][2]) # Output: 6

Interactive Keypad 📱

Kizhe ulla interactive keypad-la oru number-a click panni paarunga. Python eppadi adhoda Row and Column vechu andha number-a access pannudhu nu puriyum!

2D List Indexing

pad = [
[1, 2, 3], # Index 0 (Row 0)
[4, 5, 6], # Index 1 (Row 1)
[7, 8, 9] # Index 2 (Row 2)
]
Click a number on the keypad!
A 2D List is just a list containing other lists! Try accessing an element.
Click any button on the keypad

Your Turn! (Unga neram!)

Oru 2D list grid kuduthurukkom.

  1. Row 2 and Column 1-la irukka number-a print pannunga.
  2. Output 8 nu varanum!

Help

2D CollectionsExercise 23/7730 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