This is the problem i was given to solve: Write a function searchDirection(word, row, col, direction, grid) that takes a word to find, a row and column starting position, a direction string such as "down", and a grid, and searches for the word in the given direction only, from the given starting position. If the word is found, a message is printed and True is returned. Otherwise, nothing is printed and False is returned.
I'm supposed to use nested for loops... but I don't know how to structure them?
Here are what the outputs should look like:
searchDirection("frog", 0, 5, "down", g) should print “frog found at (0, 5) going down” and return True
searchDirection("frog", 0, 5, "right", g) should return False, without printing anything
Here is a solution using a while loop, I will leave it as an exercise for you to figure out how to convert the logic into "nested for loops" (Hint: Take a look at the More Control Flow Tools section of the official documentation):
Output: