Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 5e000b9

Browse files
Challenge 1
1 parent aec9199 commit 5e000b9

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
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))

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /