This is a program that will be run through Python 3.x. You have friend who likes
ID: 3690675 • Letter: T
Question
This is a program that will be run through Python 3.x. You have friend who likes playing crossword puzzles and word games, and every so often she'll ask you: I need a word that starts with 'inn', 11 letters? You're ready to help her now. Only question is, where do you get the word list from? In the absence of a better source, you just use one of the textfiles you have lying around, e.g. innocents.txt, which we used in class, and which contains many words. So you want to implement a function wordhelp(start, length, fname) that looks through the file with name fname and lists all words with prefix start and of length length.
Link to the text file:
http://ovid.cs.depaul.edu/Classes/CSC401-S16/innocents.txt
Explanation / Answer
def functionwordhelp(start, length, fname):
fhand = open('fname') // open the file with fname
for line in fhand:
line = line.rstrip()
if line.startswith('start') : // make sure the words begin from start
print line
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.