Skip to content

Instantly share code, notes, and snippets.

@rocapp
Created January 16, 2017 16:32
Show Gist options
  • Save rocapp/cdcc7a0661beb1ea97db0da03272fcc4 to your computer and use it in GitHub Desktop.
Save rocapp/cdcc7a0661beb1ea97db0da03272fcc4 to your computer and use it in GitHub Desktop.
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