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