Skip to content

Latest commit

 

History

History
23 lines (17 loc) · 350 Bytes

python.md

File metadata and controls

23 lines (17 loc) · 350 Bytes
layout title
base
Python cheatsheet

dict

Initialize or modify dict value:

book = {'title': 'Game of Thrones'}
book.setdefault('authors', []).append('George R.R. Martin')
# {'authors': ['George R.R. Martin'], 'title': 'Game of Thrones'}

set

Intersect two sets:

set(['w', 5, 7]) & set([7, 9, 'w'])
# set(['w', 7])