# list
# 원소(index)로 변경 가능하다.
>>> _list = list('123456789')    # _list = []
>>> _list
['1', '2', '3', '4', '5', '6', '7', '8', '9']


# set
# 원소(index)로 변경 불가
# 중복제거, Index로 접근 불가, 순서없음
>>> _set = set('123456789')     # _set = {'apple', 'orange', 'apple', 'pear', 'orange', 'banana'}
>>> _set
{'4', '6', '3', '5', '8', '2', '7', '9', '1'}


# tuple
# tuple은 list와 달리 원소(index)를 변경할 수 없다.
>>> _tuple = 12345, 54321, 'hello!'    # _tuple = (), _tuple = tuple("1234")
>>> _tuple 
(12345, 54321, 'hello!')


# dictionary
# 원소(key)로 변경 가능하다.
>>> _dict = {'jack': 4098, 'sape': 4139, 'guido': 4127}    # _dict = {}
>>> _dict
{'jack': 4098, 'sape': 4139, 'guido': 4127}
>>> _dict.keys()
dict_keys(['jack', 'sape', 'guido'])
>>> _dict.values()
dict_values([4098, 4139, 4127])
>>> _dict.items()
dict_items([('jack', 4098), ('sape', 4139), ('guido', 4127)])

>>> for k in _dict :
	print("{} : {}".format(k, _dict[k]))
	
jack : 4098
sape : 4139
guido : 4127
>>> 

>>> for k, v in _dict.items() :
	print("{} : {}".format(k, v))
	
jack : 4098
sape : 4139
guido : 4127
>>> 



>>> dic = {'name':'Smith', 'phone':'010-0987-1234', 'age':23}

>>> dic.items();
dict_items([('age', 23), ('phone', '010-0987-1234'), ('name', 'Smith')])

>>> for t in dic.items():
	print("%s ==> %s" % t);

	
age ==> 23
phone ==> 010-0987-1234
name ==> Smith



# dictionary 원소의 값 변경 및 위치 변경
>>> _list = [{'url':'1', 'title':'11'}, {'url':'2', 'title':'22'}, {'url':'3', 'title':'333'}]
 
>>> for _item in _list:
	if _item['url'] == '2':
		_item['title'] = "changed"

		
>>> _list
[{'url': '1', 'title': '11'}, {'url': '2', 'title': 'changed'}, {'url': '3', 'title': '333'}]
 
>>> for _item in _list:
	if _item['url'] == '2':
		_item['title'] = "changed2"
		_list.remove(_item)
		_list.insert(0, _item)

		
>>> _list
[{'url': '2', 'title': 'changed2'}, {'url': '1', 'title': '11'}, {'url': '3', 'title': '333'}]








# range
# sequence 목록을 만든다.
>>> _list = list('123456789')
>>> for i in range(len(_list)) :
	print(i, _list[i])

0 1
1 2
2 3
3 4
4 5
5 6
6 7
7 8
8 9



# enumerate
# sequence 있는 tuple 만든다.
>>> seasons = ['Spring', 'Summer', 'Fall', 'Winter']
>>> list(enumerate(seasons))
[(0, 'Spring'), (1, 'Summer'), (2, 'Fall'), (3, 'Winter')]

>>> for i in enumerate(seasons) :
	type(i)
	print(i)

<class 'tuple'>
(0, 'Spring')
<class 'tuple'>
(1, 'Summer')
<class 'tuple'>
(2, 'Fall')
<class 'tuple'>
(3, 'Winter')

>>> for i, item in enumerate(seasons) :
	type(i)
	type(item)
	print(i, item)
	print()

	
<class 'int'>
<class 'str'>
0 Spring

<class 'int'>
<class 'str'>
1 Summer

<class 'int'>
<class 'str'>
2 Fall

<class 'int'>
<class 'str'>
3 Winter

>>> list(enumerate(seasons, start=1))
[(1, 'Spring'), (2, 'Summer'), (3, 'Fall'), (4, 'Winter')]