Books title | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Books title

Was stuck in exception handling on python 3 The projects name book title. Anyone know how to do it?

15th Oct 2020, 1:51 AM
Zhi Xian
Zhi Xian - avatar
11 Answers
+ 3
Where's your code..
15th Oct 2020, 4:39 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 3
Bro check this out... https://code.sololearn.com/cpLd69M99SJy/?ref=app Happy Coding...
15th Oct 2020, 4:56 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 3
https://code.sololearn.com/c5LfMwEmIx2v/?ref=app compare your code with this one👆🏻
15th Oct 2020, 5:02 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 1
trying to print string chac and count the length of the content so that able print out as per sample output
15th Oct 2020, 4:51 AM
Zhi Xian
Zhi Xian - avatar
+ 1
This is a possible solution for this problem with open("/usercode/files/books.txt", "r") as file: lista = [x.strip() for x in file.readlines()] for element in lista: print('{}{}'.format(element[0], len(element)), sep='\n')
16th Oct 2020, 6:00 PM
Exequiel Burgos
Exequiel Burgos - avatar
0
given file = open(“/usercode/files/books.txt” , “r”) f = file.read() print(file.read()) title = “str()”+ len() print(title) file.close()
15th Oct 2020, 4:49 AM
Zhi Xian
Zhi Xian - avatar
0
sample output should be like read txt file content and print out like below “Harry Potter” output: H12
15th Oct 2020, 4:50 AM
Zhi Xian
Zhi Xian - avatar
0
thank so much
15th Oct 2020, 4:57 AM
Zhi Xian
Zhi Xian - avatar
0
the code is somewhat fixed there. not that really good
15th Oct 2020, 4:58 AM
Zhi Xian
Zhi Xian - avatar
0
file = open("/usercode/files/books.txt", "r") #your code goes here books=file.readlines() for i in books: if i==books[-1]: value=len(i) else: value=len(i)-1 print(i[0]+str(value)) file.close()
25th Apr 2021, 10:30 AM
A Owadud Bhuiyan
A Owadud Bhuiyan - avatar
0
file = open("/usercode/files/books.txt", "r") for line in file: words = line.split() i = "" for word in words: i += word[0] print(i) file.close()
22nd Dec 2022, 5:48 AM
Juan David Ortiz Guevara
Juan David Ortiz Guevara - avatar