Blame | Last modification | View Log | RSS feed
def shift_string(str):
'''Returns a list of strings that is the original string shifted by 1-25 places.
The input string must have no whitespaces'''
ret = []
for i in range(0,26):
output = ''
for c in str:
output += chr((ord(c)-65+i)%26 + 65) # Increment the letter by 1 mod(26) and append to output
ret.append(output)
return ret
if __name__ == '__main__':
# input = raw_input("Enter string: ")
input = 'NPVGP GIZGH LGZKP LKKLF EQZUN PGEHZ RKZOJ ZGZXZ MZQKA'
input = input.upper()
# Increment amount, here it's 26 for the english alphabet
for i in range(0,26):
output = ''
for c in input:
if c != ' ':
# Increment the letter by 1 mod(26) and append to output
output += chr((ord(c)-65+i)%26 + 65)
else:
# Ignore whitespaces
output += ' '
print output