Question: dictionary or list comprehensions, e . g . , [ * * 2 tor i in range ( 1 0 ) ] with open (

dictionary or list comprehensions, e.g.,[**2 tor i in range(10)]
with open (explicitly open and close the file instead)
the ternary operator (use an if instead)
recursion
exceptions (tryjexcept)
type annotations
importing libraries (unless a library is explicitly mentioned in the specitication)
Background
Word search is a word game that involves searching for words in a (random) grid of letters. This program simulates the game by searching for words in a grid. The program differs from the physical game in several ways:
The physical game is usually played with a 44 grid. Your program will generalize this to any NN grid ), where N is determined by the size of the grid provided (see next bullet point).
The physical game uses a random gnd. Your program wil read the grid of letters from a tile.
Definitions
Given a grid of letters G and a list of words L, a word in G is legal if it meets the following criteria:
it is at least three letters long;
. It can be formed from letters in G that are adjacent along a row (two cases: going left-to-right or right-to-left), a column (two cases: going top-to-bottom or bottom-to-top), or a diagonal (one case: going upper-left to lower-right); and
File Names
Your program should be in a file named word_search. py.(NOTE: use an underscore, not a dash.)
Expected Behavior
Write a program, in a flie named word_search. py, to do the tollowing:
Read the word-list file into a list and the grid-of-letters file into a square grid. You may assume that these files are organized as follows:
the word-list file contains one word per line;
Search this grid for legal words. Matches of words found in the grid letters separated by whitespace. (Note: The file may be empty.)
Collect the legal words found into a list and then print them out as indicated under Output format below.
Examples
The following is an example of the grid of letters file:
\table[[y,c,o,d,e,j
dictionary or list comprehensions, e . g . , [ *

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!