diff --git a/Challenge questions/anantkaushik/challenge1.py b/Challenge questions/anantkaushik/challenge1.py new file mode 100644 index 0000000..f00b027 --- /dev/null +++ b/Challenge questions/anantkaushik/challenge1.py @@ -0,0 +1,25 @@ +def encodeString(sentence): + sentence = sentence.split() + for i in range(len(sentence)): + sentence[i] = sentence[i].capitalize() + return "".join(sentence) + +def decodeString(sentence): + if not sentence: + return "" + decodedSentence = [] + word = sentence[0] + for i in range(1,len(sentence)): + if sentence[i].isupper(): + decodedSentence.append(word) + word = sentence[i].lower() + else: + word += sentence[i] + decodedSentence.append(word) + return " ".join(decodedSentence) + +sentence = input("Enter a String: ") +encodedSentence = encodeString(sentence) +decodedSentence = decodeString(encodedSentence) +print("Converted String is {}".format(encodedSentence)) +print("Original String is {}".format(decodedSentence)) \ No newline at end of file