Advanced list
processing:
v List comprehensions provide a concise way to
apply operations on a list.
v It creates a new list in which each element is
the result of applying a given operation in a list.
v It consists of brackets containing an
expression followed by a “for” clause, then a list.
v The list comprehension always returns a result
list.
list=[ expression for item in list if
conditional ]
List inside
another list is called nested list.
>>>
a=[56,34,5,[34,57]]
>>>
a[0]
56
>>>
a[3]
[34, 57]
>>>
a[3][0]
34
>>>
a[3][1]
57
Related Topics
Privacy Policy, Terms and Conditions, DMCA Policy and Compliant
Copyright © 2018-2023 BrainKart.com; All Rights Reserved. Developed by Therithal info, Chennai.