+ 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()
5 Réponses
+ 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))
+ 1
Tnx a lot✌️🌹
0
print("".join(l)) this function also not working
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()
0
can someone solve this?