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
6 Antworten
+ 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.
+ 3
Here's an example using what ChaoticDawg mentioned:
https://code.sololearn.com/cuoxFt377sb6/?ref=app
+ 3
Ah thank you ChaoticDawg
+ 3
Not a recommended way, but might be interesting:
https://code.sololearn.com/cd0zDv4l2wwu/?ref=app
+ 1
Bob_Li there you go: https://code.sololearn.com/cslnaQrtq14f/?ref=app
0
how about modifying to make it case insensitive? that could count as an improvement.