range arguments in python code example
Example 1: range python 3
arr = [19,5,3,22,13]
for i in range(len(arr)):
print(arr[i])
for i in range(2, len(arr)):
print(arr[i])
for i in range(0, len(arr), 2):
print(arr[i])
for i in range(len(arr)-1, -1, -1):
print(arr[i])
Example 2: python range in intervals of 10
print("using start, stop, and step arguments in Python range() function")
print("Printing All odd numbers between 1 and 10 using range()")
for i in range(1, 10, 2):
print(i, end=', ')
Example 3: in range python
for i in range(x) :
Example 4: range python start at 1
>>> def range1(start, end):
... return range(start, end+1)
...
>>> range1(1, 10)
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]