Python Assigning Multiple Values at Once

In Python, you can assign values to the variables. This post tells you how to assign values to multiple variables. It is common assigning values in any programming language. But Python simplifies your job by introducing this technic.


Python Assigning the Values At once.

a = 1

b = 1

c = 1

d = 1

or, you can assign simultaneously as;

a=b=c=d=1

Python Assigning Multiple Values at Once

Python Assigning Multiple Values at Once

The other way you can assign as;

a, b, c, d = 10, 1, 3.5, 'Srini'

From the above, you can understand as below:

  • The '10' assigns to a.
  • The '1' assigns to b.
  • The '3.5' assigns to c.
  • Then 'Srini' to d.

 References

  1. Python Basics Variable Assignment

Comments

Popular posts from this blog

How to Fix Python Syntax Errors Quickly

Python Ideas to Remove HTML tags

Hyperledger Fabric: 20 Real Interview Questions

Python: Swap Two Strings no need to Define Third Variable

Calculate Circle Area the Logic You Need to write in Python