Created
November 8, 2014 23:51
-
-
Save rubenerd/4b4ecef0d16c2d7e6c0d to your computer and use it in GitHub Desktop.
Basic Python string to int, and back
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
#!/usr/bin/env python | |
spam = 42 | |
eggs = "24" | |
## "Casting" form ints and strings | |
ingredients = spam + int(eggs) | |
menu = str(spam) + eggs | |
## Alternative using str method | |
vikings = spam.__str__() + eggs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment