+ 2

Swap two number without using third variable

Swap two number without using third variable. Input: a=5 b=10 Output: a=10 b=5 https://code.sololearn.com/cx2gjn0UEA46/?ref=app

6th Jan 2023, 2:25 PM
Soumya Ranjan Behera
Soumya Ranjan Behera - avatar
1 Antwort
+ 5
You can also do it using tuple and believe me it's the easiest way to swap, though it just for python a = int(input("Enter first number:- ")) b = int(input("Enter second number:- ")) print(" Before:- ", (a, b)) a, b = b, a print(" After:- ", (a, b))
6th Jan 2023, 3:15 PM
Rohit Rajendra Brahmankar
Rohit Rajendra Brahmankar - avatar