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)



Output


Picture showing the output of the list comprehension in python



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

Query/Feedback


Your Email Id  
 
Subject 
 
Query/FeedbackCharacters remaining 250