0
guys, what is wrong here???? as there are two words in input the output is has only one word #encryption_program
def WordSentence(Sentence): words = Sentence.split(" ") newWords = [word[::-1] for word in words] newSentence = " ".join(newWords) result="" s=0 for i in range(len(newSentence)): char=newSentence[i] result += chr((ord(char) + s - 97) % 26 + 97) s+=1 return result Sentence = "ganesh velmani" print(WordSentence(Sentence))
2 Réponses
+ 3
There's nothing wrong. Like you said, it's an encryption program. So the space character is also encrypted into a different character. If you only want to encrypt the non-space characters, you could try
if char == ' ':
result += ' '
else:
result += chr((ord(char) + s - 97) % 26 + 97)
+ 2
And please try to share the link of your code in the playground rather than pasting the entire code over here coz no one wants to copy or write your entire code again to check that.