Reading Between the lines


#1



https://www.codecademy.com/courses/python-intermediate-en-OGNHh/1/1?curriculum_id=4f89dab3d788890003000096


It tells me to refresh the page.


my_file = open("text.txt", "r")

print my_file.readline(1)
print my_file.readline(2)
print my_file.readline(3)

my_file.close()


#2
  1. Refresh the page
  2. Go to text.txt tab
  3. Add anything to the end of all lines
  4. Run your code

Hope this helps :slight_smile:


#3

Thank you. Fixed it right away.
Modify some letters in tab "text.txt" worked for me.


#4

No need for the line number in .readline().
.readline(1)
.readline(2)
.readline(3)
seems to return chunks of the first line.
I if someone could explain how works it would be appreciate it a lot.


#5

Thanks very much! Made it work straight away!


#6

my_file = open("text.txt", "r")
print my_file.readline()
print my_file.readline()
print my_file.readline()
my_file.close()


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.