- 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 ...

6th Dec 2022, 3:17 PM
Глеб Подлесный
Глеб Подлесный - avatar
15 Answers
+ 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.
6th Dec 2022, 3:32 PM
Lisa
Lisa - avatar
+ 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...
6th Dec 2022, 3:58 PM
Jayakrishna 🇮🇳
Jayakrishna 🇮🇳 - avatar
+ 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.
6th Dec 2022, 3:46 PM
Lisa
Lisa - avatar
+ 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.
6th Dec 2022, 3:39 PM
Jayakrishna 🇮🇳
Jayakrishna 🇮🇳 - avatar
+ 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])
7th Dec 2022, 11:02 AM
Gaurav Kaushik
+ 1
Dear u r suppose to be some school teacher. Ur answer need .. in the open() before ur path.
8th Dec 2022, 9:52 AM
Amit Saxena
Amit Saxena - avatar
0
i try from my PC
6th Dec 2022, 3:40 PM
Глеб Подлесный
Глеб Подлесный - avatar
0
wait a minute pls
6th Dec 2022, 3:40 PM
Глеб Подлесный
Глеб Подлесный - avatar
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
6th Dec 2022, 3:43 PM
Глеб Подлесный
Глеб Подлесный - avatar
0
i cant understand what is wrong
6th Dec 2022, 3:43 PM
Глеб Подлесный
Глеб Подлесный - avatar
0
how can i add correct pass to file ?console say that this pass is not correct
6th Dec 2022, 3:53 PM
Глеб Подлесный
Глеб Подлесный - avatar
0
or other question,how can i add file on server
6th Dec 2022, 3:54 PM
Глеб Подлесный
Глеб Подлесный - avatar
0
Probably you didn't close the file by using ; file.close()
6th Dec 2022, 9:55 PM
Abdul - Razaq
0
Guys messy messages, why not to put code on playground and share?
8th Dec 2022, 5:45 AM
Ilyas Bakirov
Ilyas Bakirov - avatar
0
Глеб Подлесный 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")
8th Dec 2022, 5:50 AM
Ilyas Bakirov
Ilyas Bakirov - avatar