Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

how to make your own range function in python

# 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
Comment

making your own range function in python

# 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))
Comment

making your own range function with step in python

# 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))
Comment

python range function examples

>>> 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))
[]
Comment

PREVIOUS NEXT
Code Example
Python :: pickle save dict 
Python :: no module named googlesearch 
Python :: rolling window pandas 
Python :: basic string functions in python 
Python :: Python Making a New Directory 
Python :: python - find columns that are objects 
Python :: django orm group by month and year 
Python :: layer enable time arcpy 
Python :: merge pandas datasets 
Python :: logging.basicConfig() 
Python :: take first 10 row while reading csv python 
Python :: lambda function dataframe 
Python :: Highlight Active Links in Django Website 
Python :: python datetime move forward one day 
Python :: numpy where 
Python :: how to remove some characters from a string in python 
Python :: how do a plot on matplotlib python 
Python :: python set workdir 
Python :: legend for pie chart matplotlib 
Python :: Reverse an string Using Stack in Python 
Python :: bitwise and python image 
Python :: if string in lost py 
Python :: how to hide ticks marks in plot 
Python :: how to set numerecal index in pandas 
Python :: selenium python switch tabs 
Python :: discord py fetch message 
Python :: python stack data structure 
Python :: how to fix def multiply(a ,b): a*b 
Python :: python sum of a subset 
Python :: python function docstring 
ADD CONTENT
Topic
Content
Source link
Name
9+8 =