So here is what I have. This is a program in which I have to take a random string, ex) "]][][sfgfbd[pdsbs]\bdgb"; and strip it of all special characters. the function "Strip" works for its purpose.
message=(str.lower(input("Enter a Coded message: ")))
offset=int(input("Enter Offset: "))
alphabet="abcdefghijklmnopqrstuvwxyz"
def strip(text):
print("Your Lower case string is: ",message)
print("With the specials stripped: ")
for index in text:
if index in alphabet:
print(index, end="")
print()
return strip
I need the output from strip in the "decode" function, but I can't seem to figure out anyway of storing the iterations of "index"
def decode(character):
encrypted= ""
for character in message:
global offset
if character == " ":
encrypted+= " "
elif ord(character) + offset > ord("z"):
encrypted+=chr(ord(character) +offset - 26)
else:
encrypted+= chr(ord(character)+(offset))
print("the decoded string is: ",encrypted,end=" ")
print()
So "decode" only takes the output from the original "message" input. "Palin" however succeeds in taking decode's value.
def palin(code):
print(code[::-1])
print(code[:])
if code[::-1]==code[:]:
print("This is a Palindrome!")
else:
print("This is not a Palindrome.")
return palin
print()
palin(decode(strip(message)))