How to solve the title encoder lesson 39 of python intermediate | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

How to solve the title encoder lesson 39 of python intermediate

I don't know what is wrong with this code For lesson 39 intermediate python book encoder a little help please try: file = open("/usercode/files/books.txt", "r") #your code goes here f=file.readlines() for line in f: words=line.split(" ") l=[] for word in words: l.append(word[0]) print(l) finally: file.close()

3rd Nov 2021, 4:10 AM
dear bear
dear bear - avatar
5 Answers
+ 1
Hi dear! The reason it's not working is because you're returning all characters as list items. You may find the join() method useful in this case. It joins a list of strings with another string as a separator. So, your print statement needs to be like this print("".join(l))
3rd Nov 2021, 4:45 AM
Python Learner
Python Learner - avatar
+ 1
Tnx a lot✌️🌹
4th Nov 2021, 4:55 PM
dear bear
dear bear - avatar
0
print("".join(l)) this function also not working
22nd Dec 2021, 6:37 AM
Nethula Jayalath
0
file = open("/usercode/files/books.txt", "r", "a") lines = file.readlines() for line in lines: line_list = line.split(" ") nickname = [] for word in line_list: nickname.append(word[0], end="") file.write(nickname) file.close()
1st Apr 2022, 10:56 AM
Oliver Clayden
0
can someone solve this?
1st Apr 2022, 10:56 AM
Oliver Clayden