def own_range(start=0, end=0, step=1):
if step == 0:
raise ValueError("own_range() arg 3 must be not zero")
if start > end and step < 0:
while start > end:
yield start
start += step
elif start > end or (start != 0 or end == 0) and start != 0 and end == 0:
while end < start:
yield end
end += step
elif start == 0 and end != 0 and end > 0 and step > 0 or (start != 0 or end == 0) and start != 0 and start < end and step > 0:
while start < end:
yield start
start += step
def range_by(starting_number, ending_number):
sequence = []
while starting_number < ending_number:
sequence.append(starting_number)
starting_number += 1
return sequence
print(range_by(-3,6))
range(start, stop, step)
x = range(0,6)
for n in x:
print(n)
>0
>1
>2
>3
>4
>5
range(start:optional, stop:required, step:optional)
A built-in python function to create a sequence of integers.
range(10)
range[2,9]
print(list(range(10)))
range(1,100,10)
arr_data=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20]
user = int(input("Enter the product of numbers: "))
for i in range(0,20,1):
a = arr_data[i]
for t in range(0,20,1):
b = arr_data[t]
if (a*b) == user:
print(a,"x",b,"=",user)
else:
pass
>>> list(range(10))
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
>>> list(range(1, 11))
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
>>> list(range(0, 30, 5))
[0, 5, 10, 15, 20, 25]
>>> list(range(0, 10, 3))
[0, 3, 6, 9]
>>> list(range(0, -10, -1))
[0, -1, -2, -3, -4, -5, -6, -7, -8, -9]
>>> list(range(0))
[]
>>> list(range(1, 0))
[]