I have problem with indent , how to resolve? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
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))

8th Mar 2021, 11:31 PM
Ska 2020
Ska 2020 - avatar
5 Respostas
+ 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))
8th Mar 2021, 11:59 PM
iTech
iTech - avatar
9th Mar 2021, 9:44 PM
ā¤ļøšŸ˜PreranašŸ˜ā¤ļø
ā¤ļøšŸ˜PreranašŸ˜ā¤ļø - avatar
0
I need to count numbers of words that same in text
8th Mar 2021, 11:32 PM
Ska 2020
Ska 2020 - avatar
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
9th Mar 2021, 1:53 AM
āˆ†BHāˆ†Y
āˆ†BHāˆ†Y - avatar