- 1
Length of Word
How can I give length of word and save it in int ?
7 Answers
+ 4
By using the len() function. What have you tried so far?
+ 1
your code lacks the ***INDENTATION*** of the function's code block
What exactly is it supposed to do? If it is a task from a sololearn course, mention course name and task number.
0
Why does this code have an error ?
def search(x, y) :
z = len(x)
t = len(y)
0
you did not indent the code proberly
and you never call the function or rint z or t. Is this the complete code?
0
My code is this
But the error is in line 2 and 3
def search(x, y) :
z = len(x)
t = len(y)
caunterx = 0
cauntery = 0
for i in range (0,z):
if x[caunterx] == y[cauntery] :
caunterx = caunterx + 1
cauntery = cauntery + 1
if cauntery == t
return("Word found")
break
else :
continue
i = i + 1
else :
cauntery = 0
caunterx = caunterx + 1
if caunterx == z :
return("Word not found") break
else :
continue
i = i + 1
text = input()
word = input()
print(search(text, word))
0
This is “Search Engine” project and need help to do it
0
Read the previous lesson again and use the "in" operator to test ***if x in y*** (hint!)
Also check the ***indentation*** of your code