In: Computer Science
2.
Code screenshot:
Output:
Code to copy:
# range() in python has 3 parameters
# The first one is the starting value. Here we need to print from
10 so start = 10
# The second is stop value. Here we need to print till 2 so we give
a value that comes
# just after that. So stop = 0
# The third is step. That is the increment or decrement in each
iteration
# Now using a for loop we can iterate an integer through
this range
for i in range(10, 0, -2):
# and print value that integer in each iterations
print(i)
3.
Code screenshot:
Output:
Code to copy:
# We need to give the list to the for loop and
# use an iterator to go through each element in list
for i in ["bob", "al", "bert"]:
# and print each of the elements that comes into iterator
print(i)