6. Functions split
and join
¶
Print output (drag lower right corner to resize)
|
Activity: CodeLens 6.1 (cl_l18_6_en)
6.1. Exercise¶
Write a program that asks for a birth date in the format “dd/mm/yyyy” and
converts this date to the format “<day> of <month> of <year>” using the pre-written list
months
. Save the result in the variable birth_date
and print this variable. Remember
that .split()
returns a list and you can pass the character to separate a string as an argument.
Save the day, month and year in string format in the variables day
, month
and year
.
17
date = input("date (dd/mm/yyyy): ").split("/")
months = [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December",
]
Activity: 6.1.1 ActiveCode (ac_l18_6_en)
You have attempted 1 of 3 activities on this page