Blame | Last modification | View Log | Download | 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 outputret.append(output)return retif __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 alphabetfor i in range(0,26):output = ''for c in input:if c != ' ':# Increment the letter by 1 mod(26) and append to outputoutput += chr((ord(c)-65+i)%26 + 65)else:# Ignore whitespacesoutput += ' 'print output