Professional Documents
Culture Documents
30 Lists
30 Lists
1
Python Programming
Lists
• Ordered sequence of values
• Written as a sequence of comma-separated
prutor.ai
values between square brackets
• Values can be of different types
– usually the items all have the same type
2
Programming
Lists
• List is also a sequence type
– Sequence operations are applicable
prutor.ai
3
Programming
Lists
• List is also a sequence type
– Sequence operations are applicable
prutor.ai Repetition
( )
4
Programming
More Operations on Lists
• L.pop()
• L.append(x)
• L.index(x)
• L.extend(seq)
prutor.ai
• L.insert(i, x)
• L.count(x)
• L.sort()
• L.remove(x)
• L.reverse()
• L.pop(i)
x is any value, seq is a sequence value (list, string, tuple, …),
i is an integer value 5
Programming