Last active
December 20, 2015 09:30
-
-
Save cursorial/6108621 to your computer and use it in GitHub Desktop.
Swap two integers without using a temporary variable
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = input('Enter Number 1: ') | |
b = input('Enter Number 2: ') | |
print 'Number 1: ', a | |
print 'Number 2: ', b | |
a -= b | |
b += a | |
a = b - a | |
print 'Number 1: ', a | |
print 'Number 2: ', b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment