I want to read lines 25 to 55 from a file, but the range seems to be only outputting a single number and 6 lines, when it should be 30 lines.
hamlettext = open('hamlet.txt', 'r')
for i in range (25,55):
data = hamlettext.readlines(i)
print(i)
print(data)
Output:
54
['\n', 'Mar.\n', 'O, farewell, honest soldier;\n', "Who hath reliev'd you?\n"]
Use the builtin
enumerate
function: