-2

in c / c++ i use EOF like

int n;

while( scanf("%d",&n) != EOF ){

printf("%d",n);

}

now how can i use EOF in Python ?

please give me the same code using python

πάντα ῥεῖ
  • 85,314
  • 13
  • 111
  • 183
Nasir Khan
  • 19
  • 2

1 Answers1

1

You would do something like this in python:

with open(filename, 'r') as f:
    for line in f:
        print(line)
Reblochon Masque
  • 33,202
  • 9
  • 48
  • 71