File tree Expand file tree Collapse file tree 1 file changed +25
-0
lines changed
Challenge questions/anantkaushik Expand file tree Collapse file tree 1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ def encodeString (sentence ):
2+ sentence = sentence .split ()
3+ for i in range (len (sentence )):
4+ sentence [i ] = sentence [i ].capitalize ()
5+ return "" .join (sentence )
6+
7+ def decodeString (sentence ):
8+ if not sentence :
9+ return ""
10+ decodedSentence = []
11+ word = sentence [0 ]
12+ for i in range (1 ,len (sentence )):
13+ if sentence [i ].isupper ():
14+ decodedSentence .append (word )
15+ word = sentence [i ].lower ()
16+ else :
17+ word += sentence [i ]
18+ decodedSentence .append (word )
19+ return " " .join (decodedSentence )
20+
21+ sentence = input ("Enter a String: " )
22+ encodedSentence = encodeString (sentence )
23+ decodedSentence = decodeString (encodedSentence )
24+ print ("Converted String is {}" .format (encodedSentence ))
25+ print ("Original String is {}" .format (decodedSentence ))
You can’t perform that action at this time.
0 commit comments