Lists pe iteration
fruits = ["apple", "banana", "mango"]
for fruit in fruits:
print(fruit)
Output:
apple
banana
mango
Tuples pe iteration
numbers = (10, 20, 30, 40)
for num in numbers:
print(num)
Output:
10
20
30
40
Dictionaries pe iteration
Keys ke through
student = {"name": "Amit", "age": 21, "grade": "A"}
for key in student:
print(key)
Output:
name
age
grade
Values ke through
for value in student.values():
print(value)
Output:
Amit
21
A
Keys aur Values dono
for key, value in student.items():
print(key, ":", value)
Output:
name : Amit
age : 21
grade : A
While loop recap
count = 0
while count < 5:
print("Count:", count)
count += 1
Output:
Count: 0
Count: 1
Count: 2
Count: 3
Count: 4
Next Step
Ab hum seekhenge Slice Operator, jisme strings aur lists ke particular parts nikalna sikhenge.