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