Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

Swapping Variables

x = 10
y = 11


x, y = y, x
"Swapping by simultaneously creating a tuple and unpacking it"

print(x, y)
Comment

swap variables

>>> x, y = 10, 20
>>> x, y = y, x
(20, 10)
Comment

swap variables

A = A operation B
B = A inverse-operation B
A = A inverse-operation B
Comment

PREVIOUS NEXT
Code Example
Python :: convert word to pdf python 
Python :: ValueError: only one element tensors can be converted to Python scalars 
Python :: python cat 
Python :: python trace table 
Python :: qr decomposition python 
Python :: create and activate virtual environment with python 3 
Python :: odoo model 
Python :: return function in python 
Python :: typeerror: 
Python :: sqlite query using string as parameter in python 
Python :: django venv activate 
Python :: correlation with target variable python 
Python :: how to specify symbol in matplotlib 
Python :: how to register a model in django 
Python :: django model functions 
Python :: looping over lists in python 
Python :: pip vs conda 
Python :: defaultdict item count 
Python :: python code for internet radio stream 
Python :: program to replace lower-case characters with upper-case and vice versa in python 
Python :: count item in list 
Python :: convert tuple to int 
Python :: python delete key if exists 
Python :: python file exists 
Python :: unique python 
Python :: negative slicing in python 
Python :: python get file ending 
Python :: python power of natural number 
Python :: python code to convert csv to xml 
Python :: download button image streamlit 
ADD CONTENT
Topic
Content
Source link
Name
3+7 =