0
How should I go through
def search(): if word in text: print("word found") else: print("word not found") text=input() word=input() search()
6 ответов
+ 2
🅰🅹 🅐🅝🅐🅝🅣 now i understand word (small letter w ) and Word(with capital letter W) is different although word is used as identifier and Word as string in print statement so it is always better to print a statement should start with capital letter please like if i interpreted 100% accurately correct
+ 2
The code is okay.
What's the problem?
INPUT:
Sololearn is cool platform.
cool
OUTPUT:
word found
+ 2
Akash Prasad
If you don't pass parameter in function then you have to declared variable above the function and also there is "Word" not "word"
Your code should be look like this:
text = input()
word = input()
def search():
if word in text:
print("Word found")
else:
print("Word not found")
search()
+ 2
🅰🅹 🅐🅝🅐🅝🅣 his code is also fine how and where he declared his variable.
Because as you can see
text and word was declared before the function call.
If you print text and word inside the function search() you'll see that those variables are accessible from inside the function.
+ 1
While running in code playground it is working but in submitting project its not accepting
0
🅰🅹 🅐🅝🅐🅝🅣 i tried it too