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
x = 0
while x < 10:
print ("Value of x is ", x)
x = x + 1
else:
print("Value of x is equal to 10")
For Loop
for object_variable in collection:
Statements to be executed.
name = "Karan"
for character in name:
print (character)
classmates = ["Karan","sumit","amit"]
for name in classmates:
print (name)