Level 9 : How can we swap two numbers in python without using the third variable?


x = 10
y = 20

Author: KaivalyaG | Tags: swapping | 1859+ Python FAQs | Share
staticmethod | immutable-data-type | comparison | operator-or | math-copysign | defining-functions | operand | formal-and-actual-parameter | loop | installation | overflow | floating-point-precision | multiple-inheritance | memory | multiple-inheritance | collections | map-function | python-operators | parsing-with-strptime | identity-operator | list | touples | string-method | operator | package-management | typeerror | pass | introduction-to-python | working-with-file-paths | python-syntax-and-structure | pandas | function | sys-module | using-os-and-pathlib-modules | data_structure | opening-files-(open()) | compute | sorting | match | invalid-list | counter-function | bitwise | static-method | comment | functional-programming | filtering-and-indexing | recursion | reading-and-writing-files | complex | memory-management | indentation | encoding | dictionary | command-line-parsing | dictionaries | using-map()-for-transformations | list-operation | slice | random-function | thread-synchronization | floats | class-decorators | deep-copy | list-methods-and-slicing | using-assertions-(assertequal,-assertraises) | conditional-statement | python-history | file_handling | matrix | nested-loop | introduction-to-threads | generator | data-type-conversions | assignment-operator | gil | print | precedence-and-associativity | context-manager | import-method | identity-operator | data-type | global | difference-between-threads-and-processes | string-slicing | key-value-pairs | reading:-read(),-readline(),-readlines() | conversion | min-max-function | directory-operations | id-function | lambda-functions | __all__-attribute | using-the-threading-module | precedence | built-in-function | round-function | methods | managing-directories-with-os-and-shutil | oop | string-methods | mathematical-function | identity-operators-(is,-is-not) | method-overloading | control-flow | working-with-dates-and-times | python-module | working-with-binary-files-(rb,-wb) | control-statement | literal-characters-and-special-characters | random | string-iteration | scientific-notation | print-statement | library | reading-and-writing-large-files-efficiently | asyncio-module | name-mangling | choice | list-slicing | virtual-environment | threading | descriptors | string-manipulation | data-structures | list-vs-tuple | sorted | access-modifier | numeric | loop-control | class | built-in-function | condition | head-and-tail | time-series-with-pandas | string-concatenation | tuple | __future__ | comprehension | expression | default-mutable-argument | namedtuple | thread | operations | magic-method | overriding-methods | while-else-loop | binary | matrix-list-comprehension | pep | membership-operators-(in,-not-in) | variable | heap-memory | destructor | exception-handling | recurssion | sys | using-else-and-finally | set | global-keyword | numpy | dictionary-comprehensions | boolean-masking | math | inherit | single-inheritance | working-with-temporary-files-using-tempfile | python | list-comprehension | namespace | copy | function-and-scope | lambdas | interpreter | def | mutable | exponentiation | oops | tuple-unpacking | python_version | call | pickling--unpickling | pseudocode | zip-function | using-lists-as-stacks | turtle | file-handling | tuple-methods | python-repl | list-mutation | syntax-error | input | module | objects | decorator | software-design | dictionary-methods | conditional-statement | test-discovery | virtual-environment | sorting-and-ranking | file-handling | sum() | debugging | slicing | arithmetic-operation | default-arguments | raise | polymorphism | higher-order-function | string | parameter | conditional-statements | set-operation | list-indexing | data-structure | error | formatting-with-strftime | class-and-object | datetime.date,-datetime.time,-datetime.datetime | list-comprehensions | enumerate() | data-types | sum-function | object-attribute | factorial-function | creating-custom-modules | loops | regular-expression | split | inheritance | version-check | list-comprehension | type_conversion | operator-overloading | while-and-for-loop | logical-operators | implementation | quantifiers-(*,-+,-?,-{}) | syntaxerror | postfix | docstring | join | dicts | rollback | frozenset | method | expand-tab | fabs-function | constructor | boolean | functional-programming | goto-function | stack | swapping | syntax-error | immutability | odd-number | using-yield-in-functions | anchors-(^,-$) | init | encapsulation | dataframe-and-series-objects | handling-missing-values-(fillna,-dropna) | indexing | why-use-multiprocessing-over-threading?-(gil) | error-handling | else-statement | attribute | format | tuples | python-django | datatype | binary-operation | data-structures-in-python | round | control-flow | operators | syntax | arbitrary-arguments-(*args,-**kwargs) | datetime | complex-number | data-type | mathematics | raise-statement | counter | iterable | creating-and-starting-threads | update | type-conversion | error-handling | decimal | data-structure | identifier | design-principle | advanced-file-operations | filter | benefit | string-method | application | thread-safe-data-structures-(queue.queue) | regex | built-in | bitwise-operator | bitwise-operator | file | generators-in-python | shallow-copy | else | while-loops | built-in-modules | joining-and-merging-dataframes | __init_subclass__ | iterators | functions | strings | arithmetic-expression | generators | operator-and | class-and-inheritance | int | async | class-and-instance-variable | intering | assignment-operators | range | integer | aggregating-data-with-functools.reduce() | function-argument | escape-operator | iterator | sets | return-statement | list-method | regular-expressions | version | type-conversion-and-casting | multiprocessing | lambda | string-slicing | with-statement | zip | multiple-except-blocks | zfill-function | append | exception | yield | assert | type-conversion | asyncio | basic | logical-operator | center | array | mapping-function | integers | multithreading | global-variable | unit-testing | walking-through-directories-using-os.walk() | matplotlib | boolean-and-non-boolean | exception-handling | booleans | collection | loop-control-statements | min-function | logical-operation | list-join | statement | feature | classes | input-function | global-variable | indexing:-loc-vs-iloc | writing:-write(),-writelines() | string-formatting | while-loop | list,-set,-and-dictionary-comprehensions | mysql | lists | string-formatting | input-function | logical-operator | for | introduction-to-multiprocessing | filter-function | keyword | max-min | lambda-function | using-join()-and-is_alive()-methods ...