Stop Word Printer
Python
Medium
2 views
Problem Description
Words are provided one by one. Output all words until you see the word stop (case sensitive). Do not output stop itself.
Input Format
One line: words separated by space (contains stop at least once).
Output Format
Words before stop, separated by space.
Sample Test Case
Input:
i am learning stop python is nice
Official Solution
import sys
w=sys.stdin.read().strip().split()
if not w: sys.exit(0)
out=[]
for tok in w:
if tok=='stop':
break
out.append(tok)
sys.stdout.write(' '.join(out))
Solutions (0)
No solutions submitted yet. Be the first!
No comments yet. Start the discussion!