Ask coding questions

← Back to all posts
A student here learning data handling please do help
amanh787 (0)

myfile=open("file1.txt","r")
s=myfile.read()
print(s)

can someone tell how to add files from my computer so that replit can read it

Answered by malvoliothegood (871) [earned 5 cycles]
View Answer
Comments
hotnewtop
malvoliothegood (871)
  1. You need to create a Python repl
  2. Create the text file 'file1.txt' on your computer, and fill it with some lines of text
  3. Upload the text file by dragging it from your file manager into the files area in your repl
  4. Include the code in your question in main.py
  5. Run your program!

Try getting it working yourself, then compare it to this repl: https://replit.com/@malvoliothegood/readtextfile#main.py

amanh787 (0)

@malvoliothegood Thanks a lot got it working