15,797,822 members
See more:
`want to return recursive function named find(text,substring) that will return the substring if the substring is inside the text. or return an empty string if substring is not inside the text. supposed to define a function named is_string_there(text, string) to test the find function. the function should return True if the string is inside the text or False if the string is not inside the text.`

output i want to achieve:
true
false

What I have tried:

```<pre>def find(text, substring):
if substring == is_string_there: # compare them first
return is_string_there
else:
return  # how do i return empty

def is_string_there(text, string):

print(is_string_there("I love DSAG", "DSAG"))
print(is_string_there("I love Python", "DSAG"))```
Posted
Updated 5-Feb-20 22:25pm
Richard MacCutchan 6-Feb-20 3:47am
Recursion makes no sense for a simple test like this.
def find(text, substring):
if substring == is_string_there: # compare them first
return is_string_there
else:
return # how do i return empty

def is_string_there(text, string):
if find(text, string):
return True
else:
return False

print(is_string_there("I love DSAG", "DSAG"))
print(is_string_there("I love Python", "DSAG"))

i tried running this
but the error was
false, false. not the output that i want

## Solution 1

The is_`string_there` should be something like:
Python
```def is_string_there(text, string):
if find(text, string):
return True
else:
return False```

and the `find` should be recursive, e.g.
Python
```def find(text, string):
# stop condition here
# call the function itself here, e.g. find(text[1:], string)```