Python One Line Code To Swap Two Numbers

In python, we can check swap two given numbers in one line. See example below:


firstNum = int(input('Enter first number: '))
secondNum = int(input('Enter second number: '))

firstNum, secondNum = secondNum, firstNum

print('First number = %d and second number = %d' %(firstNum, secondNum))

Output

Enter first number: 30
Enter second number: 80
First number = 80 and second number = 30