OneBite.Dev - Coding blog in a bite size

assign multiple variables in python

Code snippet on how to assign multiple variables in python

a, b, c = 5, 3.2, "Hello"

This code assigns three distinct values to three variables: ‘a’, ‘b’, and ‘c’. Each variable is assigned a specific value on the right side of the equation. On the left side of the equation, the variables are listed and separated by commas.

In this code, a is assigned the value 5 (an integer). Variable ‘b’ is assigned the value of 3.2 (a float). Lastly, ‘c’ is assigned the string “Hello”.

The values in the code can be changed. For example, if you wanted to assign a different integer value to ‘a’, replace 5 with the new integer value. The code can also be used to assign multiple values to the same variable (for example, a = 5, 6, 7).

python