input:
4
after
a b c d
f e f g
t e r r
a b i j
output wants to come : [(0, 0),(1, 0),(2, 0),(2, 1),(2, 2)]
4
search
s e a c
r c c c
h e e e
h e e e
output wants to come: "Not Present"
line = []
search_line = input("What are you looking for? ")
number = int(input("Enter search field size: "))
print("#####################################")
print("Enter the letters of the search field")
for i in range(number):
line.append([])
line[i] = input("row number " + str(i) + ", (" + str(number) + " letters): ").split(' ')
print("#####################################")
coordinate = []
error = 0
for el in range(len(search_line)):
for i in range(len(line)):
if search_line[el] in line[i]:
x = i
y = line[i].index(search_line[el])
coordinate.append((x, y))
break
else:
error = 1
print("ANSWER: ", end='')
if error == 0:
print(coordinate)
elif error == 1:
print("Not Present")
Comments
Leave a comment