Nowy kurs! Każdy programista powinien nauczyć się Generative AI!
Wypróbuj darmową lekcję0
I have problem with indent , how to resolve?
text = input('entrer texte') word = input('entrer word') def search(text , word): i = 0 for letter in word: if word in text: i += 1 return i return "Word found" else: return "Word not found" print(search(text, word))
5 odpowiedzi
+ 1
text = input('entrer texte')
word = input('entrer word')
def search(text , word):
i = 0
for letter in word:
if word in text:
i += 1
print("Word found")
return i
'''
it is not possible to use return twice in a single if block, read more about return statement!
'''
else:
return "Word not found"
print(search(text, word))
+ 1
0
I need to count numbers of words that same in text
0
0
Looks like it's the search engine project, if it's so, then your code has errors:
Remove the prompt message in the input
Remove the for loop
And indentation you can do like(here I used 1 space for indentation):
if word in text:
return "Word found"
Do Same with the else statement
Know more about indentation:
https://www.sololearn.com/post/138813/?ref=app