Articles → Python → Range function in python

Range function in python






Purpose





Syntax


range(start, end, step)











Example


print("Specifying start, end and step")
for x in range(2,21,2): # start = 3, end = 21, step 2
    print (x)
    
print("Mention only start and end")
for x in range(0,6): # start = 0, end = 6
    print (x)

print("Mention only end")
for x in range(10): # end = 10
    print (x)





Click to Enlarge


Convert range to list




print(list(range(0,5)))





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Friday, March 08, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250