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.

Updated on: 24-Jan-2020

541 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements