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 :: python string generator 
Python :: pandas dataframe map 
Python :: pandas create sample dataframe 
Python :: tkinter maximise window 
Python :: python input list of ints 
Python :: python sklearn knn regression example 
Python :: python script to convert dicom to niftii 
Python :: python pandas how to select range of data 
Python :: subset in python 
Python :: python make 1d array from n-d array 
Python :: list_display django foreign key 
Python :: python turtle shapes 
Python :: remove from list if not maches in list 
Python :: add values to tuple python 
Python :: python sort algorithm 
Python :: Error: getaddrinfo ENOTFOUND www.python.org www.python.org:443 Downloading Python failed. Error: { Error: getaddrinfo ENOTFOUND www.python.org www.python.org:443 
Python :: pandas groupby multiple columns 
Python :: create an array with a range of elements 
Python :: python remove one character from a string 
Python :: gaierror at /members/register [Errno 11001] getaddrinfo failed 
Python :: Check np.nan value 
Python :: how to make a variable global in python 
Python :: how to append in dictionary in python 
Python :: python merge list of dict into single dict 
Python :: add a tuple to a dictionary python 
Python :: django forms date picker 
Python :: python list contains string 
Python :: requests save file python 
Python :: binary tree in python 
Python :: python mann kendall test 
ADD CONTENT
Topic
Content
Source link
Name
2+4 =