Articles → Python → List comprehension in python

List comprehension in python






Purpose





Example




out = []

for x in range(1,5):
    out.append(x)

print (out)




out = []

out = [x for x in range(1,5)]

print (out)





Click to Enlarge


Posted By  -  Karan Gupta
 
Posted On  -  Monday, March 11, 2019

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250