iterate multiple sequences with zip a = 'apple', 'banana', 'mango' b = 1, 2, 3 list_test = list(zip(a, b)) print(list_test) # >>> [('apple', 1), ('banana', 2), ('mango', 3)] dict_test = dict(zip(a, b)) print(dict_test) # >>> {'apple': 1, 'banana': 2, 'mango': 3} Python/Python__works 2019.06.03
set combinations and operators #introducing python #set combinations and operators a = {1, 2} b = {2, 3} print(a & b) print(a.intersection(b)) >>> {2} print(a | b) print(a.union(b)) >>> {1,2,3} print(a-b) print(a.difference(b)) >>> {1} print(a^b) print(a.symmetric_difference(b)) >>>{1, 3} Python/Python__works 2019.06.03
Dictionaries intoducing python Dictionaries #튜플 생성 empty_tuple = () one_tuple = ('test') #multiple variables assign test_tuple = ('apple', 'banana', 'mango') a, b, c = test_tuple print(a) >>> apple print(b) >>> banana #리스트로 튜플 생성 test_list = ['apple', 'banana', 'mango'] tuple(test_tuple) print(test_tuple) >>> ('apple', 'banana', 'mango') #Dict 생성 empty_dict = {} #리스트를 Dict로 convert 1) test_list = [[1,2],[3,4.. Python/Python__works 2019.06.03