Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is a python 3 program, In this program, it is supposed to open a file and create a list of each line and then

This is a python 3 program,

In this program, it is supposed to open a file and create a list of each line and then create a dictionary where the fist index of each line is the key the rest are the values. It then prompts the user to enter a word which is supposed to be a key and it would create a list of what is supposed to be its stress syllables that make up a rhyme. Im having difficulty in trying to check the other keys in the dictionary have those same stress syllables at the end of the its list and print it out.

This is my code:image text in transcribed

Here is the file that im using:

SUPERCILIOUS S UW2 P ER0 S IH1 L IY0 AH0 S SICILIAN S IH0 S IH1 L IY0 AH0 N SILEO S IH1 L IY0 OW0 LILLY L IH1 L IY0 CHILE CH IH1 L IY0 CHILI CH IH1 L IY0 SILLINESS S IH1 L IY0 N AH0 S SILLY S IH1 L IY0 RECORD R AH0 K AO1 R D RECORD R IH0 K AO1 R D SWORD S AO1 R D

and this is an example of what should be the result:

image text in transcribed

- def reads_file: file- input( f open(file).readlines word_list for words in f word L1st.append words.splito) return word_list -def create dict(word list): rhyme_words- rhyme_words-fitems [0]: items [1:] for items in word_list return rhyme_words - def choose_word(rhyme_words): word_selcted- input('select word to rhyme: .upperO for i in rhyme_words: if i word_selcted: phoneme -rhyme_words[i] for char in range( Lencphoneme)): word phoneme [char] if wordr-11 '1' scheme-phoneme[char:] #if a key has an entire list that is identical to the one given by the input it shouldnt print it # it should only print if 'scheme' is the same at the end of the word print(scheme) printO return scheme s Search Stack Data ExceptionsDebug I/O Python Shell Messages os Commands Ignore this Options Debug I/O (stdin, stdout, stderr) appears below select word to rhyme: chili C'IH1', 'L', "IY0']

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions