# subcribe to my channel
# https://www.youtube.com/channel/UCakNP54ab_3Qm8MPdlG4Zag
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
# plz suscribe to my youtube channel -->
# https://www.youtube.com/channel/UC-sfqidn2fKZslHWnm5qe-A
def range_by(starting_number, ending_number):
#sequence = [starting_number]
sequence = []
while starting_number < ending_number:
sequence.append(starting_number)
starting_number += 1
return sequence
print(range_by(-3,6))
# plz suscribe to my youtube channel -->
# https://www.youtube.com/channel/UC-sfqidn2fKZslHWnm5qe-A
def range_with_step(start_num,end_num,step_num=1):
sequence2 = [start_num]
while start_num < end_num:
start_num += step_num
sequence2.append(start_num)
return sequence2
print(range_with_step(0,6,3))
>>> 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))
[]