project_python/3.1_lesson.4.20.py

17 lines
689 B
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

***Задание 2 Параграф 3.1***
***Напишите программу, которая сокращает заголовки до требуемой длины.
Если заголовок длиннее, он должен быть усечён и завершён многоточием ....
Если заголовок помещается в заданную длину — выводите его без изменений.***
if name == "main":
length = int(input())
count = int(input())
for _ in range(count):
string = input()
if len(string) <= length:
print(string)
else:
print(f'{string[:length - 3]}...')