problem
Sometimes some words like "localization" or "internationalization" are so long that writing them many times in one text is quite tiresome.
Let's consider a word too long, if its length is strictly more than 10 characters. All too long words should be replaced with a special abbreviation.
This abbreviation is made like this: we write down the first and the last letter of a word and between them we write the number of letters between the first and the last letters. That number is in decimal system and doesn't contain any leading zeroes.
Thus, "localization" will be spelt as "l10n", and "internationalization» will be spelt as "i18n".
You are suggested to automatize the process of changing the words with abbreviations. At that all too long words should be replaced by the abbreviation and the words that are not too long should not undergo any changes.
using language : python3
from string import ascii_lowercase
low = list(ascii_lowercase)
user_low = []
user_input = input()
def convert(list):
s = [str(i) for i in list]
res = ("".join(s))
return res
for num in range(0,int(user_input)):
count = 0
user_speling = input()
user_speling = list(user_speling)
if len(user_speling) > 10:
for check in range(1, len(user_speling)-1):
for check1 in low:
if user_speling[check] == check1 :
count += 1
print(user_speling[0]+str(count)+user_speling[int(len(user_speling))-1])
else:
print(convert(user_speling))
'알고리즘(Python,Java)' 카테고리의 다른 글
[codeforces] A. String Task (0) | 2019.08.21 |
---|---|
[codeforces] A. Next Round (0) | 2019.08.21 |
[codeforces] A. Theatre Square (0) | 2019.08.15 |
[Codeforeces] A. Watermelon (0) | 2019.08.15 |
백준알고리즘 2798번: 블랙잭 (0) | 2019.08.15 |
#IT #먹방 #전자기기 #일상
#개발 #일상