def solution(src: str) -> str:
# your code here
dic = {}
str1 = ''
ls = [i for i in string.ascii_letters[:26]]
for k in ls:
for i in src:
if i in ls:
if src.count(i) <= 9:
dic[i] = src.count(i)
else:
dic[i] = 9
if k in list(dic.keys()):
str1 = str1 + str(dic[k])
else:
str1 = str1 + '0'
return str1
if __name__ == '__main__':
assert solution("$aaaa#bbb*cc^fff!z") == "43200300000000000000000001"
assert solution("z$aaa#ccc%eee1234567890") == "30303000000000000000000001"
def solution(src: str)-> str:
# your code here
ascii_list = [chr(97+i) for i in range(26)]
ascii_dict = dict.fromkeys(ascii_list,"0")
for item in src:
if ascii_dict.get(item):
ascii_dict[item] = str(int(ascii_dict[item]) + 1)
return "".join(list(ascii_dict.values()))
assert solution("$aaaa#bbb*cc^fff!z") == "43200300000000000000000001"
assert solution("z$aaa#ccc%eee1234567890") == "30303000000000000000000001"
def solution(src: str)-> str:
# your code here
result = [x for x in '0' * 26]
for string in set(list(src)):
if 97 <= ord(string) <= 122:
result[ord(string) - 97] = str(list(src).count(string))
return "".join(result)
def solution(src: str) -> str:
from string import ascii_lowercase as al
dic = dict.fromkeys(al, 0)
for s in set(src.lower()):
if al.__contains__(s):
dic[s] = src.lower().count(s)
return "".join(str(s) for s in dic.values())
def solution(src: str) -> str:
result = "".join([chr(x) for x in range(97, 123)])
for s in list(src):
anscil = ord(s)
if 97 <= anscil <= 122:
if result.find(s) >= 0:
result = result.replace(s, str(src.count(s)))
for r in list(result):
try:
f = float(r)
except ValueError:
result = result.replace(r, "0")
return result
assert solution("$aaaa#bbb*cc^fff!z") == "43200300000000000000000001"
assert solution("z$aaa#ccc%eee1234567890") == "30303000000000000000000001"
def solution(src: str) -> str:
l = [chr(97 + i) for i in range(26)]
result = []
for i in l:
if i in src:
result.append(src.count(i))
else:
result.append(0)
return ''.join([str(i) for i in result])
assert solution("$aaaa#bbb*cc^fff!z") == "43200300000000000000000001"
assert solution("z$aaa#ccc%eee1234567890") == "30303000000000000000000001"
def solution(src: str)-> str:
li = [str(src.count(chr(i))) if chr(i) in src else "0" for i in range(97, 123)]
return "".join(li)
assert solution("$aaaa#bbb*cc^fff!z") == "43200300000000000000000001"
assert solution("z$aaa#ccc%eee1234567890") == "30303000000000000000000001"
def solution(src: str)-> str:
import string
#from collections import Counter
return ''.join(str(test_key.count(i)) for i in string.ascii_lowercase)
#return ''.join([str(Counter(src)[i]) for i in string.ascii_lowercase])
def solution(src: str)-> str:
import re
a = re.findall('[a-z]', src)
ls = [i for i in string.ascii_letters[:26]]
b=[k for k,v in itertools.groupby(a)]
for i in ls:
if i in b and a.count(i)<=9:ls[ls.index(i)]=str(a.count(i))
elif i in b and a.count(i)>9:ls[ls.index(i)] = '9'
else:ls[ls.index(i)]='0'
return ''.join(ls)
def solution(src: str) -> str:
base_list = [chr(i) for i in range(97, 123)]
src_list = [src[i] for i in range(len(src)) if src[i].isalpha()]
return ''.join([str(src_list.count(base_list[i])) for i in range(len(base_list))])
assert solution("$aaaa#bbb*cc^fff!z") == "43200300000000000000000001"
assert solution("z$aaa#ccc%eee1234567890") == "30303000000000000000000001"