- 3

Help me solve that code project

in python core course there is a project call (Book titles) i can't solve it please help me

17th Nov 2021, 3:30 PM
Hayam Mohammed
Hayam Mohammed - avatar
12 Respuestas
+ 4
So in this challenge you need to read through the file. The file is opened for you in the starter code. You can use a for in loop to read the file. For each line print the first character of the title using [0] syntax. Then print the length of the title len(). You can use .replace to get rid of the newline replace \n with "" Don't forget to close the file.
17th Nov 2021, 5:16 PM
Paul K Sadler
Paul K Sadler - avatar
+ 8
Post your attempt here so we can help
17th Nov 2021, 4:18 PM
Morteza Hajji
+ 6
Post your attempt here. So we can try to know where is the problem
17th Nov 2021, 3:31 PM
MATOVU CALEB
MATOVU CALEB - avatar
+ 4
Post your attempt (code) here so we can coach you.
17th Nov 2021, 4:04 PM
Paul K Sadler
Paul K Sadler - avatar
+ 3
str(len(line.replace("\n", "")))
17th Nov 2021, 5:35 PM
Paul K Sadler
Paul K Sadler - avatar
+ 2
If yes, the the code would be like this: result= 0.01 * 2**30 print(result) That mean we are doubling the initial value (.01) 30 times.
17th Nov 2021, 5:16 PM
Morteza Hajji
+ 2
Morteza Hajji thanks alot for your answer but the project isn't about Exponentiation
17th Nov 2021, 5:29 PM
Hayam Mohammed
Hayam Mohammed - avatar
+ 2
Paul K Sadler Now it works thank you But i didn't understand how to get ride of the newline The code still include the newline in len()
17th Nov 2021, 5:31 PM
Hayam Mohammed
Hayam Mohammed - avatar
17th Nov 2021, 5:04 PM
Hayam Mohammed
Hayam Mohammed - avatar
+ 1
By this link just the general python course opened. you mean projec part basic? Exponentiation?
17th Nov 2021, 5:09 PM
Morteza Hajji
0
Paul K Sadler now it works 🙏 Thanks so much
17th Nov 2021, 5:41 PM
Hayam Mohammed
Hayam Mohammed - avatar
0
#Program to check if word appears on sentence text. text = input() word = input() j = "Word found" k = "Word not found" def search(text, word): for i in text: if text == i: return j else: return k print(search(text, word)) #hi folks this is the final project on Python for beginners, it is a basic search engine, my code only outputs correct results 3 out of 6 times, can you please help me , I am almost done🙏🏽
18th Aug 2022, 7:12 AM
Dumisani Dlamini