Answer to Question #340210 in Python for nandu

Question #340210

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"


1
Expert's answer
2022-05-12T08:20:30-0400
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")

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS