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!!