Sololearn: Learn to Code
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3
To get it run, file.seek() needs an argument = 0. So with: file.seek(0) it should work.
7th Apr 2020, 7:32 PM
Lothar
Lothar - avatar
+ 1
file.read() method only reads file print (file.read()) prints content read in file
7th Apr 2020, 6:56 PM
Sudarshan Rai
Sudarshan Rai - avatar
+ 1
In case of your program, the first file.read() will place the file pointer to the end, because it will consume all characters from the file. So the print(file.read()) that comes afterwards, will always be empty. To re-read the content, you can use file.seek() to position the pointer back to the beginning.
7th Apr 2020, 7:12 PM
Tibor Santa
Tibor Santa - avatar