question, inquiry, enquiry, query, ask a question, question, make inquiries , inquire

Asked 2 years ago, Updated 2 years ago, 165 views

ddd

list loops file

2022-09-22 21:38

1 Answers

with open("test.txt") as f:
    y = f.readlines()

z = input("Word : ")
a = z.split()

for count, line in enumerate(y):
    if all(j in line for j in a):
        print(count+1, line)

I organized it a little bit.

with open("test.txt") as f:
    y = f.readlines()

z = input("Word : ")
a = z.split()

for count, line in enumerate(y):
    if all(j in line.split() for j in a):
        print(count+1, line, end="")

You might have intended this.


2022-09-22 21:38

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.