I'm trying to write a function that determines if a letter is present at a certain row and column on a list of lists.
#Input:
lst2 = [['.', 'W', 'W', 'E', 'E'],
['.', '.', '.', '.', 'f'],
['A', 'A', 'A', '.', 'f']]
#Output: is_space_occupied(0, 1, lst2) should return True because 'W' is present on that spot
while is_space_occupied(1, 1, lst2) should return False because '.' is present on
that spot and not a letter.
This is the code I have so far:
def letter_on_spot(row,col,lst):
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
for row in lst:
for col in lst:
if col == A:
return True
else:
return False
Edit: I'm getting return outside function as an error for return True and am not sure if my function works correctly