0

Error in line 13 - where starts the "while"

'' this is the last exercise of python" text = input() word = input() print (len(text)) print (len(word)) i = 0 A = len(text) def search(text, word): while int(i) <= int(A): If (text[i] = word[b]): i +=1 b +=1 Else i +=1 b = 0 Elif i = len(word): Print "word found" break print "not found" print(search(text, word))

30th Sep 2021, 2:38 PM
Pincho Jvnil
4 Antworten
0
The error happens because you have created function by def search(text, word): but there is nothing in it, so compiler thinks you just forgot TAB before while loop.... Also is this code for "Search Engine" code project? if so, dont you think you are over-complecating things? The solution for this problem could be written in 10 lines easily, using "if word in text: " statement....
30th Sep 2021, 3:00 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar
0
Pls Save code in playground and share link here.. otherwise it's difficult to find : for ex: " Else " is it automatic capitalisation ? It must be "else"
30th Sep 2021, 2:59 PM
Jayakrishna 🇮🇳
0
There are so many errors in that code, so I think you should go back to the lessons in the Python course and learn how to write proper code.
30th Sep 2021, 3:02 PM
Jan
Jan - avatar
0
Quantum , lol true... Pincho Jvnil , btw just letting you know that your output string should also start with capital letter, or otherwise tests will fail....
30th Sep 2021, 3:05 PM
Aleksei Radchenkov
Aleksei Radchenkov - avatar