Scanning till EOF in python -
one way know how
while 1: try: n=int(raw_input()) except: break
any other way shorter ?
by shorter mean consumes lesser number of characters.
for following code, read()
call block until eof encountered:
import sys sys.stdin.read()
or line @ time consume less memory:
import sys line in iter(sys.stdin.readline, ''): pass
Comments
Post a Comment