Finish filling out the following Python code ''' Goal: implement a caesar substitution cipher where the key is an integer from 1 - 25 ''' def caesar(txt, key): out_str = '' # force key to be in range key = key % 26 alpha = 'abcdefghijklmnopqrstuvwxyz' alpha2 = alpha + alpha for c in txt: ''' fill in ''' return out_str
Finish filling out the following Python code
'''
Goal: implement a caesar substitution cipher
where the key is an integer from 1 - 25
'''
def caesar(txt, key):
out_str = ''
# force key to be in range
key = key % 26
alpha = 'abcdefghijklmnopqrstuvwxyz'
alpha2 = alpha + alpha
for c in txt:
'''
fill in
'''
return out_str
We need to write the missing lines of the Python code.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images
Can you explain the lines:
out_str += chr((ord(c) + key-97) + 97)
else:
out_str+= chr((ord(c) + key - 65) + 65)
Specifically, why you use the numbers 97 and 65.
Also - what is included in the parameter "txt"? Is it the same as the "text" variable?
Thank you- I'm still very much a beginner (obviously)