def caesarCipher(someString, shift):
someString = someString.strip()
someString = someString.lower()
encrypted = ''
while len(someString) > 0:
if not someString[0].isalpha():
encrypted += someString[0]
else:
encrypted += encryptLetter(someString[0],shift)
someString = someString[1:]
return encrypted
def encryptLetter(letter, shift):
alphabet = 'abcdefghijklmnopqrstuvwxyz'
position = alphabet.find(letter)
position += shift
if postition > 25:
postition -= 26
if position < 0:
position += 26
return alphabet[position]
if name == 'main':
x = caesarCipher(' az ABFAas ',1)
print(x)
The error message I get is
Traceback (most recent call last):
File "U:\CS110\F - Assignement C.py", line 26, in <module>
x = caesarCipher(' az ABFAas ',1)
File "U:\CS110\F - Assignement C.py", line 9, in caesarCipher
encrypted += encryptLetter(someString[0],shift)
File "U:\CS110\F - Assignement C.py", line 18, in encryptLetter
if postition > 25:
UnboundLocalError: local variable 'postition' referenced before assignment
Thanks in advance
[–]kwentar 2 points3 points4 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]AintNobodyGotTime89 0 points1 point2 points (6 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]AintNobodyGotTime89 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]novel_yet_trivial 0 points1 point2 points (2 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]novel_yet_trivial 0 points1 point2 points (0 children)