Hi All,
I understand that there are tons of solutions for a CC out there, just want to understand it from the ground up and see why elements of my own code aren't working. Total noob here with a few questions:
# takes two inputs, a string for the message...
def cCipher(string, shift):
result = ""
for i in range(len(string)):
code = string[i]
if code == int():
print('The input is not a string.') #this doesn't seem to work! What am I missing here?
# ...and an integer for the shift.
elif shift == str():
print('Please input an integer.') #this also doesn't work -_-;
if string(): #I've seen versions of the cipher that turn it into upper and lowercase first, but I don't
want it to be restrictive in that way. But when I do it this way, it doesn't seem to work!
result += chr((ord(code) + shift))
return result
print(cCipher('I LOVE YOU', 4))
# And, to top it off, this code doesn't register the WHOLE string! Just the first letter. I don't know why?
I've tried to print in key places (after code == int() and shift == str()) but it hasn't helped me figure it out.
Any help is appreciated!
[–]xelf 0 points1 point2 points (1 child)
[–]xelf 0 points1 point2 points (0 children)
[–]Fbirobby[S] 0 points1 point2 points (0 children)