0
Python Project
file = open("/usercode/files/books.txt", "r") #your code goes here file.close() I need to read the title one by one and output the code for each book on a separate line .
9 Respostas
+ 6
Baribor Saturday ,
(your code sample does not meet the requirements of the task description, and it is just a code without any comments / descriptions)
please do not give codes to the ops. this does not help to improve the coding ability and gaining the experience. you also take away the opportunity for the op to improve himself and to develop further.
better to give hints or a description how the task can be solved. this a sample how to support the op:
https://code.sololearn.com/c3JEh3fi2VdK/?ref=app
+ 3
Attemps?
+ 3
Repeating the question does not help.
We have not seen an attempt from you
https://www.sololearn.com/Discuss/3046302/?ref=app
+ 3
Mbalenhle Shamima Nhlapo
file is an object so you cannot write (in file)
As explanation is already given
Use readlines function to read file, which will return list of books.
Now as description says output should be first character + no_of_characters of books but each book contains \n in the last which should be replace by a space.
For example: Harry Potter
So first character is H and length is 12 so
H12
+ 1
Mbalenhle Shamima Nhlapo
You have to read file not write file.
Check previous lesson again.
+ 1
Lothar
Okay. I thought that was just a personal work
0
file = open("/usercode/files/books.txt", "r")
for i in file:
file.write(i+ "\n")
file.close()
0
Here is my attempt i was trying to post it here
0
I am looking at my previous lessons i am clearly trying and failing thats why i am asking for help , if i knew what i was doing i would not be asking