Editor settings

General settings

Save settings

Learn to program with Python

Assigning a Variable with another Variable #

In Python, we can assign the value of one variable to another variable using the assignment operator =. The value on the right side of the operator is assigned to the variable on the left side. For example, if we have a variable x with the value 10, we can assign it to another variable y like this:

x = 10
y = x

Now the value of y is also 10. We can also reassign the value of x later, and it will not affect the value of y since it was only assigned the value of x at the time of assignment.


Exercise #

  • Create a new variable x and assign the number 10 to it.
  • Create another variable y and assign the variable x to it.
Output will be displayed here