Skip to main content

Coroutines in Python

 



def searcher():
    import time

    f = open("data.txt")
    f1 = open("data2.txt")
    book2 = f.read()
    book = f.read()
    # time.sleep(3)



    while True:
        text = (yield)
        if text in  book or book2:
            print("Data Found",text)

        else:
            print("Data not Found",text)

search = searcher()
next(search)

a = input("Enter name ")
search.send(a)

Comments