0

How to find a word in a group of letters (python)

For example: x=input() #lets say that the user typed in ‘iowbchandlekv’ and now I want to check if ‘hand’ as a whole word is in x, how would I do this?

19th Feb 2022, 5:58 PM
Bailey
4 Respostas
+ 2
try this: https://code.sololearn.com/cVTGoZ9c279v/?ref=app if you want to see if a contains b then you can use: b in a #or a.find(b)!=1
19th Feb 2022, 6:04 PM
Sousou
Sousou - avatar
+ 1
Just iterate through the string and compare each character ( you can use the casefold function to make it suitable for caseless comparisions)
19th Feb 2022, 6:10 PM
A J
A J - avatar
0
I forgot one of my questions, how would I cut off everything before hand now that it has been found?
19th Feb 2022, 6:09 PM
Bailey
0
str.find(word) should suffice
21st Feb 2022, 1:43 PM
PythÞñ CĂșltĂźstâš”ïžđŸ”„đŸ‡łđŸ‡Ź
PythÞñ  CĂșltĂźstâš”ïžđŸ”„đŸ‡łđŸ‡Ź - avatar