+ 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()
9 Réponses
+ 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()
+ 2
but it says task not completed((
+ 2
Title encoder
+ 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
+ 2
Code please?
+ 2
Help please?
+ 2
What?
+ 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()
+ 1
Try please?