I am getting the following error:
##this is the error message i receive
Traceback (most recent call last):
File "C:\Users\a\Des ktop\checkerboa rd", line 26, in <module>
print(checkerbo ard(plaintext))
File "C:\Users\a\Des ktop\checkerboa rd", line 20, in checkerboard
ciphertext=ciph ertext+idx
TypeError: Can't convert 'int' object to str implicitly
I am running out of ideas to make this thing work. I have to complete this encryption cipher with the number representing each letter corresponding to the index of the letter in one of the three strings.
For string2 and 3 however i have to have the index corresponding to the first space in string1 at the front of the index number corresponding to each of those letters in string2 and the index of the second space in string1 in front of the index number for letters corresponding to string3. That part i haven't quite figured out yet.
##this is the error message i receive
Traceback (most recent call last):
File "C:\Users\a\Des ktop\checkerboa rd", line 26, in <module>
print(checkerbo ard(plaintext))
File "C:\Users\a\Des ktop\checkerboa rd", line 20, in checkerboard
ciphertext=ciph ertext+idx
TypeError: Can't convert 'int' object to str implicitly
I am running out of ideas to make this thing work. I have to complete this encryption cipher with the number representing each letter corresponding to the index of the letter in one of the three strings.
For string2 and 3 however i have to have the index corresponding to the first space in string1 at the front of the index number corresponding to each of those letters in string2 and the index of the second space in string1 in front of the index number for letters corresponding to string3. That part i haven't quite figured out yet.
Code:
def checkerboard(plaintext):
string1='estonia r '
string2='bcdfghjklm'
string3='pquvwxyz,/'
plainstripped=''
for ch in plaintext:
if ch.isalpha():
plainstripped=plainstripped+ch
plainstripped=plainstripped.lower()
ciphertext=' '
for ch in plainstripped:
if ch in string1:
idx=string1.index(ch)
ciphertext=ciphertext+idx
elif ch in string2:
idx=string2.index(ch)
ciphertext=ciphertext+idx
else:
idx=string3.index(ch)
ciphertext=ciphertext+idx
return ciphertext
plaintext= 'What is Going On123'
print(checkerboard(plaintext))
Comment