- 3

Hello world. Can someone help me with module 5 program?

15th Mar 2021, 6:25 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
16 Antworten
+ 3
Which exactly help do you need? Clarify task? Fix program? Other?
15th Mar 2021, 6:26 PM
#0009e7 [get]
#0009e7 [get] - avatar
+ 2
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ Loop over the lines of the file. For each line in the file get the first letter in the line (As shown, something like line[0], where line is the loops variable name) and concatenate that with the length of the line excluding the trailing whitespace newline character '\n' if present. (The last line of the file doesn't have a newline character). You can use the .strip() method on the line to remove the newline character if present and then get the len() of the line and concatenate it to the first letter then output it.
15th Mar 2021, 7:23 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ, use `s[0]` to take the first character from the string `s`. That is what you want?
15th Mar 2021, 6:37 PM
#0009e7 [get]
#0009e7 [get] - avatar
+ 1
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ, each user has their own code for Practice, Project and Code Coach tasks. 🤦 We can see it if you copy your code, paste it in Code Playground, save it and give us the link.
15th Mar 2021, 6:41 PM
#0009e7 [get]
#0009e7 [get] - avatar
+ 1
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ, on SoloLearn, those tasks were especially made for people to solve it individually... 🤦🤦🤦 We in Discuss tab can only clarify task or fix the code...
15th Mar 2021, 6:51 PM
#0009e7 [get]
#0009e7 [get] - avatar
+ 1
ChaoticDawg thank u
15th Mar 2021, 7:29 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
+ 1
file = open("/usercode/files/books.txt", "w") file.write("Harry potter \n" "The Hunger Games\n" "Pride And Prejudice\n" "Gone With The Wind \n") file.close() file = open("/usercode/files/books.txt", "r") try: for i in file: counter=0 print(i[0]+str((len(i)-1))) counter+=1 finally: file.close() Got output: H12 T16 P19 G18 if someone missingT15 instead of T16 ..... don't worry...by putting some space or removing some space.... you need to get output...thats the question....
21st Mar 2021, 8:59 AM
Nikhil PN
Nikhil PN - avatar
0
Hi! what exactly can't you do?
15th Mar 2021, 6:34 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
0
Ярослав Вернигора(Yaroslav Vernigora) i don't know how to take kai first letter. Maybe with list[0]?
15th Mar 2021, 6:35 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
0
do you want to take the first letter of a word separately?
15th Mar 2021, 6:37 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
15th Mar 2021, 6:38 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
0
a task called book titles?
15th Mar 2021, 6:41 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
15th Mar 2021, 6:47 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
0
get You have been asked to make a special book categorization program, which assigns each book a special code based on its title. The code is equal to the first letter of the book, followed by the number of characters in the title. For example, for the book "Harry Potter", the code would be: H12, as it contains 12 characters (including the space). You are provided a books.txt file, which includes the book titles, each one written on a separate line. Read the title one by one and output the code for each book on a separate line. For example, if the books.txt file contains: Some book Another book Your program should output: S9 A12
15th Mar 2021, 6:48 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar
0
he needs a little push. Unfortunately, I haven't solved this problem myself yet. Until I got to her
15th Mar 2021, 6:53 PM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
- 1
get i can't do it
15th Mar 2021, 6:26 PM
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ
ΘΟΔΩΡΗΣ ΦΕΡΕΝΤΙΝΟΣ - avatar