Skip to content

Instantly share code, notes, and snippets.

@Kamori
Created February 4, 2017 03:59
Show Gist options
  • Save Kamori/44f074192f4fe2d2823a4f808ac978d3 to your computer and use it in GitHub Desktop.
Save Kamori/44f074192f4fe2d2823a4f808ac978d3 to your computer and use it in GitHub Desktop.
Python 2.7.12 (default, Oct 11 2016, 05:24:00)
[GCC 4.2.1 Compatible Apple LLVM 8.0.0 (clang-800.0.38)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> mymessage = "secret message"
>>> while not len(mymessage) % 5 == 0:
... mymessage += 'X'
...
>>> print mymessage
secret messageX
>>> mymessage_iterations = len(mymessage) / 5
>>> for i in xrange(mymessage_iterations):
... print mymessage[i*5]
...
s
t
s
>>> for n in xrange(5):
... for i in xrange(mymessage_iterations):
... print mymessage[n+i*5]
...
s
t
s
e
a
c
m
g
r
e
e
e
s
X
>>> secret_message = []
>>> for n in xrange(5):
... for i in xrange(mymessage_iterations):
... secret_message.append(mymessage[n+i*5])
...
>>> print ''.join(secret_message)
stse acmgreeesX
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment