This post is a continuation of Python Sequences.

Concatenating Sequences

You can concatenate sequences using the plus (+) operator:

1
2
>>> [1, 2] + [3, 4]
[1, 2, 3, 4]

Multiplying Sequences

You can multiply a sequence by an integer number to repeat it the specified number of times:

1
2
>>> [1, 2] * 3
[1, 2, 1, 2, 1, 2]

Membership

You can verify if a value is inside a sequence by using the in operator. This operator returns a Boolean specifying if the value was or not found:

1
2
3
4
>>> 4 in [1, 3, 5, 7]
False
>>> 3 in [1, 3, 5, 7]
True

Getting the length of a Sequence

1
2
>>> len([1, 3, 5, 7])
4

Getting lowest member of a Sequence

1
2
>>> min([1, 3, 5, 7])
1

Getting highest member of a Sequence

1
2
>>> max([1, 3, 5, 7])
7
[ programming  python  ]
Python virtual environments programming python
Introduction to PIP programming python
Writting Django applications for your project programming python
Setting up a Django work environment programming python
Introduction to Object Oriented Programing in Python programming python