• 1
    Input and Output Data
    • Tasks
  • 2
    Conditions
    • Tasks
  • 3
    For Loop
    • Tasks
  • 4
    Strings
    • Tasks
  • 5
    While Loop
    • Tasks
  • 6
    Lists
    • Tasks
  • 7
    Two-Dimensional Arrays
    • Tasks
  • 8
    Dictionaries
    • Tasks
  • 9
    Sets
    • Tasks
  • 10
    Functions and Recursion
    • Tasks
  • к

Lesson 4. Lines

Difficulty level:

Task«"Creative" font»

💻 Python

you & mdash; Graphic designer in the creative agency "Pixel Perfect". Your new client, the startup "Cosmo Link", wants to get a unique and memorable text style logo. Their idea & mdash; Create a feeling of "cosmic spare" and technological. You have come up with a special algorithm for transforming the text, which, in your opinion, is ideal.

rn

You need to write a program that automates this process. The program should accept the name of the brand to the input and convert it to the following rules:

rn
    rn
  1. mergers: & nbsp; first you need to get rid of From all spaces, so that the letters merge into a single whole, symbolizing the connection (link).
  2. rn
  3. & nbsp; then, then, then, then, then, then, then, then To give weight and significance, each letter or symbol is duplicated.
  4. rn
  5. status: & nbsp; And confidently, the whole line is transferred to the upper register.
  6. rn
  7. durability: & nbsp; finally, to create the very "cosmic" effect and cosmic "effect and cosmic" effect and space effects Readability, a gap is added between each pair of identical characters.
  8. rn rn

    Technical requirement: & nbsp; if an empty line or line is supplied to the input, Consisting only of spaces, the program should consider this by a mistake and display the message: & nbsp; the name cannot be empty!

    rn

    Your task & mdash; To implement this algorithm using cycles and work with lines.

    rn

    & nbsp;

    Input format

    The name of the brand for the logo (line).

    Output format

    The modified line for the logo (line). Or error message if the line was empty (line).

    Example

    Input

    cosmo link

    Output

    cc oo ss mm oo ll ii nn kk

    Hint

    There will be no clue here, decide for yourself!

main.py
Test 1
Test 2
Test 3
Test 4
Test 5
Test 6
Test 7
Test 8
Test 9
Test 10
Developer’s solution
# Получаем исходную строку от пользователя
original_text = input()

# Проверяем, не является ли строка пустой или состоящей только из пробелов
# Метод strip() удаляет пробелы в начале и в конце строки. Если после этого строка пустая, значит, в ней не было ничего кроме пробелов.
if not original_text.strip():
    # Если строка пустая, выводим сообщение об ошибке
    print("Название не может быть пустым!")
else:
    # Шаг 1: Удаляем все пробелы из строки
    text_no_spaces = original_text.replace(' ', '')

    # Создаем пустую строку, в которую будем записывать результат
    final_logo = ""

    # Шаг 2, 3 и 4: Проходим по каждому символу в строке без пробелов
    for char in text_no_spaces:
        # Преобразуем текущий символ в верхний регистр, удваиваем его и добавляем пробел
        final_logo += char.upper() + char.upper() + " "
    
    # В конце убираем лишний пробел, который добавился после последней пары символов
    print(final_logo.strip())

🎉 Congratulations! 🎉

You did an excellent job with the task! It was a challenging problem, but you found the correct solution. You are one step closer to mastering programming! Keep up the good work, because every stage you pass makes you even stronger.

AD

Advertisement

red-snake blue-snake green-snake

Running your code...

AI Helper

Hi! I am your programming assistant. Ask me anything about Python — I can explain functions, methods, and help you understand the current task!