
- Python Basic Tutorial
- Python - Home
- Python - Overview
- Python - Environment Setup
- Python - Basic Syntax
- Python - Comments
- Python - Variables
- Python - Data Types
- Python - Operators
- Python - Decision Making
- Python - Loops
- Python - Numbers
- Python - Strings
- Python - Lists
- Python - Tuples
- Python - Dictionary
- Python - Date & Time
- Python - Functions
- Python - Modules
- Python - Files I/O
- Python - Exceptions
Basic List Operations in Python
Lists respond to the + and * operators much like strings; they mean concatenation and repetition here too, except that the result is a new list, not a string.
In fact, lists respond to all of the general sequence operations we used on strings in the prior chapter.
Python Expression | Results | Description |
---|---|---|
len([1, 2, 3]) | 3 | Length |
[1, 2, 3] + [4, 5, 6] | [1, 2, 3, 4, 5, 6] | Concatenation |
['Hi!'] * 4 | ['Hi!', 'Hi!', 'Hi!', 'Hi!'] | Repetition |
3 in [1, 2, 3] | True | Membership |
for x in [1, 2, 3]: print x, | 1 2 3 | Iteration |
- Related Articles
- Basic Tuples Operations in Python
- Basic Operations supported by a list in Javascript
- Basic Operations for Queue in Data Structure
- Basic operations and Working of LOB
- C# Program to perform all Basic Arithmetic Operations
- Explain the basic mathematical operations on irrational numbers.
- Program to find number of operations needed to convert list into non-increasing list in Python
- Java Menu Driven Program to Perform Basic String Operations
- Explain the basic mathematical operations by using 2y and 5.
- Basic Operators in Python
- String Operations in Python\n
- Common string operations in Python
- Python Boolean Operations
- Basic Calculator II in Python
- Checking information about basic I/O operations on I/O subsystems in SAP HANA

Advertisements