Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

List Comprehension

# Python program to demonstrate list
# comprehension in Python
   
# below list contains square of all
# odd numbers from range 1 to 10
odd_square = [x ** 2 for x in range(1, 11) if x % 2 == 1]
print (odd_square)
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #List #Comprehension
ADD COMMENT
Topic
Name
9+4 =