This commit is contained in:
Михаил Капелько
2023-12-28 13:33:48 +03:00
父節點 16026a7b47
當前提交 d893364ff4
共有 93 個文件被更改,包括 2130 次插入0 次删除

查看文件

@@ -0,0 +1,24 @@
def shortenName(text):
capitals = [l for l in text if l.isupper()]
# Нет заглавных.
if len(capitals) == 0:
return text
capId = 0
# Первая - заглавная.
if text[0].isupper():
capId = 1
# Заглавная лишь первая.
if (
capId == 1 and
len(capitals) == 1
):
return text
# Убираем первое заглавное слово.
if capId == 1:
capitals = capitals[1:]
# Есть ещё заглавные.
firstCap = text.find(capitals[0])
return text[:firstCap] + "".join(capitals)