Python last lesson 45 search engine | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Python last lesson 45 search engine

My code works fine but would like to see someone improve it by making a few small changes just to learn how i could have done it different for my own learning purposes. Thank you https://code.sololearn.com/c3vyCNWb6O1F/?ref=app

14th Dec 2021, 9:38 PM
Chris Biddamaa
Chris Biddamaa - avatar
6 Answers
+ 4
You could have literally just done the following in your search function: if word in text: ... else: ... You didn't actually need to split and loop etc.
14th Dec 2021, 10:30 PM
ChaoticDawg
ChaoticDawg - avatar
+ 3
Here's an example using what ChaoticDawg mentioned: https://code.sololearn.com/cuoxFt377sb6/?ref=app
14th Dec 2021, 10:31 PM
Simon Sauter
Simon Sauter - avatar
+ 3
Ah thank you ChaoticDawg
14th Dec 2021, 10:35 PM
Chris Biddamaa
Chris Biddamaa - avatar
+ 3
Not a recommended way, but might be interesting: https://code.sololearn.com/cd0zDv4l2wwu/?ref=app
15th Dec 2021, 5:04 PM
Herr Rozwel
Herr Rozwel - avatar
16th Dec 2021, 3:07 PM
Herr Rozwel
Herr Rozwel - avatar
0
how about modifying to make it case insensitive? that could count as an improvement.
16th Dec 2021, 9:25 AM
Bob_Li
Bob_Li - avatar