Python 작업책 레벨 8.4
다음 URL이 주어집니다:
url = 'http://test.com/dir1/dir2/dir3/page.html';
이로부터 폴더들을 리스트 형태로 추출하세요:
['dir1', 'dir2', 'dir3']
다음과 같은 피라미드를 화면에 출력하세요:
1
22
333
4444
55555
666666
7777777
88888888
999999999
22
333
4444
55555
666666
7777777
88888888
999999999
다음 구조에 저장된 도시와 그 나라의 리스트가 주어집니다:
data = [
{
'country': 'country1',
'city': 'city11',
},
{
'country': 'country2',
'city': 'city21',
},
{
'country': 'country3',
'city': 'city31',
},
{
'country': 'country1',
'city': 'city12',
},
{
'country': 'country1',
'city': 'city13',
},
{
'country': 'country2',
'city': 'city22',
},
{
'country': 'country3',
'city': 'city31',
},
]
데이터 구조를 다음과 같이 바꾸는 코드를 작성하세요:
[
'country1': {
'city11', 'city12', 'city13',
},
'country2': {
'city21', 'city22'
},
'country3': {
'city31', 'city32'
},
]