• 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
  • к

Занятие 4. Lines

Difficulty level:

Task«Lottery»

you work as an analyst in the company conducting the lottery. Every day, Lototron gives out a very long sequence of characters in which winning numbers are encrypted. Your task & mdash; Help players by writing a program that automatically extracts all unique numbers from this mishmash of symbols. These numbers, located in the order in which they first met, will compose a “happy combination” of the day.

rn

technical tasks: write a program that takes one line on the input. The program should analyze this line and find all unique numbers in it (0-9). From the unique numbers found, you need to form a new line, maintaining the order of their first appearance. If not a single figure was found in the input line, the program should display the message: “Another circle!”.

Input format

One line that can contain any characters: letters, numbers, punctuation marks. (Type: string/string)

Output format

a line containing only unique numbers from the input line in the order of their first appearance. Or the message "Another circle!" If there are no numbers. (Type: string/string)

Example

Input

winnings: 48-15-16-23-42. Repeat: 4, 8.

Output

4815623

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
# Получаем от пользователя строку, которая может содержать любые символы.
input_string = input()

# Создаем пустую строку, в которую будем записывать найденные уникальные цифры.
unique_digits = ""

# Начинаем цикл, который перебирает каждый символ во входной строке.
for char in input_string:
    # Проверяем, является ли текущий символ цифрой.
    if char.isdigit():
        # Если это цифра, проверяем, не добавляли ли мы ее ранее в нашу строку с результатами.
        if char not in unique_digits:
            # Если такой цифры еще нет, добавляем ее в конец строки с результатами.
            unique_digits += char

# После завершения цикла проверяем, осталась ли наша строка с результатами пустой.
if unique_digits == "":
    # Если строка пуста (цифр не было найдено), выводим специальное сообщение.
    print("Еще один круг!")
else:
    # Иначе, выводим строку, содержащую уникальные цифры.
    print(unique_digits)

🎉 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...

Помощник ИИ

Привет! Я твой помощник по программированию. Задавай любые вопросы по Python, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!