Created
May 31, 2011 19:47
-
-
Save thcipriani/1001133 to your computer and use it in GitHub Desktop.
Reverse string iteration
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
k = 'Tardis' | |
i = 0 | |
for letter in k: | |
i -= 1 | |
print k[i] | |
# This will also work - extended slice method to reverse string: | |
# k = 'words' | |
# k = k[::-1] | |
# for letter in k: | |
# print letter |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment