- 2
What i do wrong ?
i have been struggling with this issue for a looooong period of time file = open("/storage/emulated/0/download/pull_ups.txt") what is wrong in this code ?why this pass is not correct ?I check this way several times but nothing work ...
15 ответов
+ 5
What is it supposed to do? What are you trying to achieve? Please link your complete code.
If it is a sololearn task, please mention course name and task number.
+ 4
For the task use this link only..
file = open("/usercode/files/pull_ups.txt")
#Even from pc, if you try it in Sololearn web version, your link won't work.
So that's why, The link is already given in the task in description. Don't change it. It access server file. Your link access your mobile storage, which is not supported by SL.
And task asks to print read text of nth line of file I think. Add that statement before file.close()
Hope it helps...
+ 3
The files is on sololearn's server, not on your local device.
Open the file.
Read the line from the file.
Close the file.
You need to get integer input to read the specific line in the file.
+ 2
The link seems to be a local storage of mobile. It works fine if you try it in your pc Or laptop from system IDEs.
But from sololearn, it won't work as sololearn don't access your local storage.
+ 1
solo learn will most likely work with files on its servers not your local storage
#Try using any of these this instead
file = open("/usercode/files/pull_ups.txt")
#To create files on solo Learn server and then write and then close it.
file = open("pull_ups.txt")
#Simply to create file for your usage then dont forget to close the file
#use this instead to avoid mistake of forgetting to close file
with open("/usercode/files/pull_ups.txt") as file: #by using this format you do not need to close the file
n = int(input()
nthday = file.readlines()
//nthday contails a list of all lines from the f
print(nthday[n])
+ 1
Guys messy messages, why not to put code on playground and share?
+ 1
Глеб Подлесный don't use absolute/full path for the file location. If file is located in the same folder as your python file just use:
ℹ️f = open("test.txt")
+ 1
Dear u r suppose to be some school teacher.
Ur answer need .. in the open() before ur path.
0
i try from my PC
0
wait a minute pls
0
file = open("C:\Users\Expert PC\AppData\Local\Programs\Opera GX\pull_ups.txt")
n = int(input())
#ваш код
file.close()
That code from pc and this is task 47.2 in python course
0
i cant understand what is wrong
0
how can i add correct pass to file ?console say that this pass is not correct
0
or other question,how can i add file on server
0
Probably you didn't close the file by using ;
file.close()