try for loop python

Solutions on MaxInterview for try for loop python by the best coders in the world

showing results for - "try for loop python"
Yusuf
02 Aug 2016
1try:   
2    with open('sample.txt','r') as file:
3        for line in file:
4            (some action here)
5except IOError:
6    except IOError as (errno, strerror):
7        print "I/O error({0}): {1}".format(errno, strerror)
8