range()
` function in a `for
` loop :# Using the range() function in a for loop
for i in range(5):
print(i)
print("Done.")
0
1
2
3
4
Done.
for
` loop to iterate over a range of numbers generated by the `range()
` function. The `range(5)
` function generates a sequence of integers from `0
` up to, but not including, `5
`.print()
` function to print each number in the range.print()
` statement outside the loop
, which prints the message "Done
."range()
` function to generate a sequence of numbers to iterate over in a loop. The `range()
` function can take one, two, or three arguments, specifying the start, end, and step size of the sequence.