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