MCPcopy Create free account
hub / github.com/Vishruth-S/CompetitiveCode / cipher

Function cipher

Misc/Caesar_Cipher_Encryptor/solution2.py:17–39  ·  view source on GitHub ↗

this function ciphers a string using the caesar's cipher method string: the message to cipher key: the number of times to shift the letters in the alphabet it returns the ciphered string

(string, key)

Source from the content-addressed store, hash-verified

15
16
17def cipher(string, key):
18 """
19 this function ciphers a string using the caesar's cipher method
20 string: the message to cipher
21 key: the number of times to shift the letters in the alphabet
22 it returns the ciphered string"""
23
24 nletters = shift(letters, key)
25
26 def cipher_word(string):
27 msg = []
28
29 for i in string:
30 index = letters.index(i)
31 i = nletters[index]
32 msg.append(i)
33
34 return "".join(msg)
35
36 sentence = string.split(" ")
37 nsentence = list(map(cipher_word, sentence))
38
39 return " ".join(nsentence)
40
41
42if __name__ == "__main__":

Callers 1

solution2.pyFile · 0.85

Calls 1

shiftFunction · 0.85

Tested by

no test coverage detected