Articles → Python → Loops In Python
Loops In Python
What Are Loops?
Types Of Loops
- While loop
- For loop
While Loop
While condition:
Statements to be executed
x = 0
while x < 10:
print ("Value of x is ", x)
x = x + 1
Click to Enlarge
x = 0
while x < 10:
print ("Value of x is ", x)
x = x + 1
else:
print("Value of x is equal to 10")
Click to Enlarge
For Loop
for object_variable in collection:
Statements to be executed.
name = "Karan"
for character in name:
print (character)
Click to Enlarge
classmates = ["Karan","sumit","amit"]
for name in classmates:
print (name)
Click to Enlarge