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