Learn practical skills, build real-world projects, and advance your career

The for loop is used to iterate over a sequence and other iterable objects. The syntax for "For" loop in python is

for val in sequence:
statements

Languages = ["Python", "C", "R"]
for x in Languages:
  print(x)
Python C R

The while loop is used to iterate over a block of code as long as the condition is true. The syntax for while loop in python is

while test_expression:
statements

counter = 1
while counter < 6:
  print(counter)
  counter += 1
1 2 3 4 5

The if…else statement is for decision making.The syntax for if else statement in python is

if test expression:
statement(s)