Created
May 2, 2017 14:51
-
-
Save Hanaasagi/b3815dc870af229fc4124beffeb7bcb7 to your computer and use it in GitHub Desktop.
flatten a list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def flatten(seq): | |
l = [] | |
for elt in seq: | |
t = type(elt) | |
if t is tuple or t is list: | |
for elt2 in flatten(elt): | |
l.append(elt2) | |
else: | |
l.append(elt) | |
return l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
tkinter
的做法