Issue
Is there a way to scan an unknown number of elements in Python (I mean scan numbers until the user writes at the standard input eof(end of file))?
Solution
raw_input
(input
in Python 3) throws EOFError
once EOF is reached.
while 1:
try:
num = int(raw_input("enter a number: "))
except EOFError:
break
Answered By - nneonneo Answer Checked By - Timothy Miller (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.