---
title: "Discussion on \"How to swap two variables value in python?\" | Hashnode"
description: "Discussion on \"How to swap two variables value in python?\". For example, If you have a equal to 1 and b equal to 2 then get output a equal to 2 and b equal to 1.\nFirst create c variable then set c equal to a, a equal to b and b equal to c.\nHere is code,\na = 1\nb = 2\n\nprint(\"OLD a = \",a)\nprint(\"OLD b = \",b)\n\nc ..."
url: "https://hashnode.com/posts/how-to-swap-two-variables-value-in-python/63ec00df457a1976cc81e58e"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How to swap two variables value in python?](https://kingarunesh.hashnode.dev/how-to-swap-two-variables-value-in-python?utm_source=hashnode&utm_medium=feed)

For example, If you have a equal to 1 and b equal to 2 then get output a equal to 2 and b equal to 1. First create c variable then set c equal to a, a equal to b and b equal to c. Here is code, a = 1 b = 2 print("OLD a = ",a) print("OLD b = ",b) c ...

Feb 14, 2023 · 1 min read · kingarunesh.hashnode.dev  
Read the article

-   [#python](https://hashnode.com/tag/python)
-   [#python-beginner](https://hashnode.com/tag/python-beginner)
-   [#python-questions](https://hashnode.com/tag/python-questions)
-   [#python-interview](https://hashnode.com/tag/python-interview)
-   [#intro-to-programming](https://hashnode.com/tag/intro-to-programming)

## Written by

[Arunesh kumar](https://hashnode.com/@kingarunesh)

@kingarunesh

  
[View profile](https://hashnode.com/@kingarunesh)

## Responses

Markdown supported · ⌘↵ to post

No responses yet.
