+ 1
How to check a word in string in python 3
..
15 Respostas
+ 7
word = input("Enter word to find:")
string = input("Enter string: ")
if word in string:
print("Word is in string")
+ 7
Hmmmm. That will work if the string is separated by a space. What if it's not separated by a space?
+ 7
Out of curiosity, may I see your code? I may have misinterpreted something. This is what I thought you were trying to do.
https://code.sololearn.com/c7sRxYYE7t8H/?ref=app
+ 3
word = "hello"
string = "hello world"
if word in string:
print("Word is in string")
+ 1
It has to check the hello world string by word
+ 1
word = "hello"
string = input("Enter string: ")
if word in string:
print("Word is in string")
0
If the input is given by user
0
Try the code
0
It will work but
0
It will work but the user is going to give input he won't give hard coded values
0
I had finded answer
0
N= input().split(" ")
By this statement we can separate a word from string
0
If the string is not separated means how its said to be a word
0
Of course yours also correct
0
But wait for mine in will send now