+ 1

Nothing happens when I try to read a file

I created a txt file called filename in the same directory with the python file that I'm working on but when I run the program, nothing really shows up file = open("filename.txt", "r") cont = file.read() print(cont) file.close()

12th Oct 2020, 12:46 PM
Hosea
5 Réponses
+ 2
I know you might have done the below step: The txt file should have something in it. Something like abcd or any text
12th Oct 2020, 12:50 PM
Steve Sajeev
Steve Sajeev - avatar
+ 1
Steve Sajeev ohhh silly me
12th Oct 2020, 12:54 PM
Hosea
+ 1
Did you do this in sololearn or your pc's ide
12th Oct 2020, 12:55 PM
Steve Sajeev
Steve Sajeev - avatar
+ 1
on PC, actually sololearn doesn't provide TRY IT YOURSELF for this session for some reason but thanks man it works now i remember writing something in it except I didn't save the txt, just a minor prob
12th Oct 2020, 12:59 PM
Hosea