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

Занятие 1. Entering and output of data

Difficulty level:

Task«Convertation of date formats»

write a program that receives a date in the & nbsp; dd mm-ggg & nbsp; and displays it to & nbsp; GGG/mm/DD .

Input format

one line containing a date in the & nbsp; dd mm -GGGGG , where DD is a day, mm - a month, and GGG - year.

Output format

One line containing the same date, but in the & nbsp; GGG/mm/DD

Example

Input

09-12-1995

Output

1995/12/09

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
# Считываем входную строку с датой
date_string = input()
# Разбиваем строку по символу '-' на три части: день, месяц, год.
# В результате получается список из трех строковых элементов.
# Например, для "09-12-1995" получится список ['09', '12', '1995']
parts = date_string.split('-')
# Извлекаем каждую часть в отдельную переменную для наглядности
day = parts[0]    # '09'
month = parts[1]  # '12'
year = parts[2]   # '1995'
# Соединяем (конкатенируем) части в новом порядке,
# используя в качестве разделителя символ '/'
new_date_format = year + '/' + month + '/' + day
# Выводим полученный результат на экран
print(new_date_format)

🎉 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, я могу рассказать о функциях, методах, обьяснить то, что тебе не понятно, а так же о текущей задаче!