From 3d9a48adfe5a46ff26bafa1ee38f543020165a4e Mon Sep 17 00:00:00 2001 From: Saksham Garg Date: Tue, 29 Jun 2021 21:24:47 +0530 Subject: [PATCH] Create StringChallenge.py --- StringChallenge.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 StringChallenge.py diff --git a/StringChallenge.py b/StringChallenge.py new file mode 100644 index 0000000..da5eed9 --- /dev/null +++ b/StringChallenge.py @@ -0,0 +1,12 @@ +def fun(strParam): + count = 0 + outParam = '' + for i in range(1, len(strParam)): + if strParam[i] == strParam[i-1]: + count+=1 + else: + outParam = outParam + str(count+1) + strParam[i-1] + count = 0 + outParam = outParam + str(count+1) + strParam[i] + return outParam +print(fun(input()))