Professional Documents
Culture Documents
Ap 12
Ap 12
Pemrograman
List
Comprehension
Adi
adi4vista@gmail.com
List Comprehensions
• List : [1, 2, “a”, 3.14]
• List Comprehensions:
– alternative cara untuk membuat/membentuk list
dengan menggunakan expression.
– bentuk umum:
• [transform iteration filter]
– [expr for val in collection]
– [expr for val in collection if <test>]
– [expr for val in collection if <test1> and <test2>]
– [expr for val1 in collection1 for val2 in collection2]
examples
examples
examples
examples
examples
examples