1

how to get a match string from stdin?

import sys

def loop():
        for word in sys.stdin:
                print(word)
                if word == 'shai':
                        print('yes')
loop()  

the function only return: john

shai

eli

david

gabi

haim

shalom

eliran

yonit

I expected to show the word 'yes' if the function see the word 'shai' in stdin.

0 Answers0