-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

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
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
  • 35,405
  • 10
  • 55
  • 80