# 2D LIST, help w/ functions! SOS

Hello… I really need some help with my programming exercise! I’m a beginner, have been studying a python course for some time now. The exercise is like this one:

first, there’s a dictionary:

ANIMALS: {
“a”: “monkey”
“b”: “dog”
“c”: “cat”
“d”: “donkey”
}
Ok, then, you have to create 2 functions.
The function will search a cell, if there is an animal (“a”, “b”, etc.) then it will print “A monkey is found from cell (3, 4).” 3 being x-coordinate and 4 y-coordinate. If there is nothing, then it prints nothing.
Something like…

def search_cell(item, row, column):
if… ???
print(“A {} is found from cell {},{}”.format(animal, x, y))

Then the second function, where it searches the whole field, every cell, for animals. Loops are needed for this. I was thinking something like:
def seach_field(field):
for row in field:
for column in row:
search_cell(item, row, column)

This is the field:

field= [
[" ", “a”, " ", " “, “b”],
[” ", “c”, “d”, “c”, " "],
[“a”, " ", “a”, “d”, " "]
]

I hope you guys get the idea. I just don’t know how to do this, I’m totally lost, esp. with the first function. I hope someone is able to help me, give me some advice?! Thank you in advance!!

Hello @py9481456786, welcome to the forums! To start, you need to figure out how a list index corresponds to the row/column given to the function. Forget about the rest, just do that. Once you’ve done that, you can move on.

Once you have finished that, the logic will require you to check to see if the letter found is `in` (hint, hint) the dictionary of animals.

2 Likes