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

Popular posts from this blog

Detect support for Shoutcast ICY MP3 without navigator.userAgent in Firefox? -

web - SVG not rendering properly in Firefox -

java - JavaFX 2 slider labelFormatter not being used -