6. Functions split and join

1text = "potato when born"
2print(text.split())
3date = "02/21/2011"
4print(date.split("/"))
5ip = "198.188.10.144"
6print(ip.split("."))
7places = ["Palmeiras", "Santos", "Corinthians"]
8print("/".join(places))
line that just executed

next line to execute

Print output (drag lower right corner to resize)
Frames
Objects

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.

Activity: 6.1.1 ActiveCode (ac_l18_6_en)

You have attempted 1 of 3 activities on this page