Created
January 16, 2017 16:32
-
-
Save rocapp/cdcc7a0661beb1ea97db0da03272fcc4 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 haiku(sdict): | |
sdict = dict([(sk, sv) for sk, sv in sdict.items() if len(sk) >= 3]) | |
first_5 = choose_words(sdict, 5, 0) | |
seven = choose_words(sdict, 7, 1) | |
sec_5 = choose_words(sdict, 5, 2) | |
first_line = ' '.join(first_5) | |
second_line = ' '.join(seven) | |
third_line = ' '.join(sec_5) | |
hai = ', '.join([first_line, second_line, third_line]) | |
with open('haiku.txt', 'a+') as h: | |
h.write(hai+'\n') | |
return hai |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment