
- 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
Multiple Assignments to Single Value in Python
Python allows you to assign a single value to several variables simultaneously. For example −
a = b = c = 1
Here, an integer object is created with the value 1, and all three variables are assigned to the same memory location. You can also assign multiple objects to multiple variables. For example −
a,b,c = 1,2,"john"
Here, two integer objects with values 1 and 2 are assigned to variables a and b respectively, and one string object with the value "john" is assigned to the variable c.
- Related Articles
- How to check multiple columns for a single value in MySQL?
- Print Single and Multiple variable in Python?
- How to assign same value to multiple variables in single statement in C#?
- How to provide multiple statements on a single line in Python?
- MySQL query to increase item value price for multiple items in a single query?
- Would you recommend to define multiple Python classes in a single file?
- How to save multiple plots into a single HTML file in Python Plotly?
- Program to find maximum credit we can get by finishing some assignments in python
- Why doesn’t Python have a “with” statement for attribute assignments?
- How to write a single MySQL query for displaying a value for multiple inputs?
- Passing Multiple ids to single parameter in MySQL?
- How to convert a single character to its integer value in Python?
- Convert a list of multiple integers into a single integer in Python
- Multiple COUNT() for multiple conditions in a single MySQL query?
- How to combine multiple groups to single Test in TestNG?

Advertisements