Create a text.txt file and than read lines


#1

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

print my_file.readline()
print my_file.readline()
print my_file.readline()

my_file.close()`

please create a text.txt file and than read lines


Finished Python but it won't let me get passed 5/9
#2

THANK YOU!! This worked!!!


#3

Why should we open the file in write mode before we open the file in read mode to make it work ?


#4

Thank you! This worked and got me out of stuck..
But I don't figure out why "my_file = open("text.txt", "w")" is neccesary even though we don't actually write anything into it...