Skip to content

Instantly share code, notes, and snippets.

@cursorial
Last active December 20, 2015 09:30
Show Gist options
  • Save cursorial/6108621 to your computer and use it in GitHub Desktop.
Save cursorial/6108621 to your computer and use it in GitHub Desktop.
Swap two integers without using a temporary variable
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