new_listes(poem_line):
r""" (list of str) -> list of str
Return a list of lines from poem_lines
"""
new_list = []
for line in poem_lines:
new_list.append(clean_up(line))
return new_list
Precondition: len(poem_lines) == len(pattern[0])
Return a list of lines from poem_lines that do not have the right number of
syllables for the poetry pattern according to the pronunciation dictionary.
If all lines have the right number of syllables, return th
"""
k = ""
i=0
lst = []
for line in new_listes(poem_lines):
for word in line.split():
for sylables in word_to_phonemes[word]:
for char in sylables:
k = k + char
if k.isdigit():
i=i+1
return i
So for the body this is what I've written so far. I have a list of words built from phonemes (['N', 'EH1', 'K', 'S', 'T']
for the word next
) and I would like to check how many digits are there (1
in EH1
makes it 1
for word `next) but I get back a 0.
I've tried moving my code around to different indentation but I'm not sure how to proceed from there.