Answers for "for loop range function list in python"

1

range function with for loop in python

# Syntax - range(start, stop, step) - you must use integers, floats cannot be used

for i in range(3):
    print(i)
# output - automatically taken start = 0 and step = 1, we have given stop = 3 (excluding 3)

for i in range(0, 4):
    print(i)
# output - We have given start = 0 and stop = 4 (excluding 4), automatically taken step =1

for i in range(0, 5, 2):
    print(i)
# output - We have given start = 0, stop = 5 (excluding 5), step = 2

for i in range(0, -4, -1):
    print(i)
# output - We can go even backwards and also to negative numbers
Posted by: Guest on December-25-2021
2

for i in range python

for i in range(start, end):
  expression
Posted by: Guest on October-07-2020

Code answers related to "for loop range function list in python"

Python Answers by Framework

Browse Popular Code Answers by Language