Ask coding questions

← Back to all posts
beginner trying to ask about python
HorikitaSuzune (0)

Hello im new to python and in this online ide. Can i ask how to code the "how to read a text file in python" in this online ide??

Answered by 19ecal (228) [earned 5 cycles]
View Answer
19ecal (228)

Reading text files is simple
First, create a text file.
Click on the add file button.

Type a file name, then .txt and hit enter
Inside the file, add whatever you want
Then go back to your and put this code

#Create a file object (replace <your-file-name> with your file name)
#Read it
#Output the contents
#Close the file

That should output whatever you put inside your text file

HorikitaSuzune (0)

thank you so much XD