+ 2

Header encoder tack python

#hello, it is not working(( help me please file = open("/usercode/files/books.txt", "r") #Š²Š°Ńˆ ŠŗŠ¾Š“ for line in file: print (line[0]+str(len(line)- line.count('\n'))) # print(f'{line[0]}#{str(len(line.rstrip()))}') #lines = file.readlines() # print(lines[1][0] + str(len(lines[1]))) file.close()

4th Mar 2022, 8:36 AM
Rasl
Rasl - avatar
9 Answers
+ 4
Do it like this file = open("/usercode/files/books.txt", "r") for i in file: x = i.split() for j in x: print(j[0],end='') print() file.close()
5th Mar 2022, 11:13 AM
Simba
Simba - avatar
+ 2
but it says task not completed((
4th Mar 2022, 8:45 AM
Rasl
Rasl - avatar
+ 2
Title encoder
4th Mar 2022, 9:00 AM
Rasl
Rasl - avatar
+ 2
In that project, you need to take the first letters of each word in the title and combine them. There is nothing to do with new line character. First you can take all the book names seperately using for loop then try taking out the first letter from each word of the book name. Lastly print out the first letter of each word using the for loop Side note: you may use end="" to print out the letters in the same line
4th Mar 2022, 11:38 AM
Simba
Simba - avatar
+ 2
Code please?
4th Mar 2022, 11:41 AM
Rasl
Rasl - avatar
+ 2
Help please?
4th Mar 2022, 5:31 PM
Rasl
Rasl - avatar
+ 2
What?
5th Mar 2022, 9:26 AM
Rasl
Rasl - avatar
+ 2
# not worked(((((( file = open("/usercode/files/books.txt", "r") #variant 1 #for line in file: # print(f'{line[0]}#{str(len(line.rstrip()))}') #variant 2 #q = file.readlines() #for i in range(len(q)): # print (q[i][0]+str(len(q[i]) - #q[i].count('\n'))) #variant 4 #for line in file: # print (line[0]+str(len(line) - #line.count('\n'))) #variant 4 #x=str(file.readlines(1)) #v=str(file.readlines(2)) #c=str(file.readlines(3)) #b=str(file.readlines(4)) #print(x[2]+str(len(x)-6)) #print(v[2]+str(len(v)-6)) #print(c[2]+str(len(c)-6)) #print(b[2]+str(len(b)-4)) #variant 5 lines = file.readlines() print(lines[1][0] + str(len(lines[1]))) file.close()
5th Mar 2022, 10:21 AM
Rasl
Rasl - avatar
+ 1
Try please?
5th Mar 2022, 7:38 AM
Simba
Simba - avatar