How to make a bool return true/false using the return function inside def in Python?

Viewed 193

I was given a task to make a code which takes a word, checks if there are any vowels in it, then returns true if there are vowels inside the word, and false if no vowels are there inside the given word. This is what I wrote-

def search4vowels(word):
    vowels = set('aeiou')
    found = vowels.intersection(set(word))
    return(bool(found))
        
search4vowels('test')

Here, I was expecting found to contain either none (Or 0 vowels) or the value of the vowels. Then use the return function with bool to get true or false depending on the value of the variable found However, when I ran the code, nothing was printed. I also changed the last line under def return(bool(found)) to return bool(found) but that did not print anything either. This might be a really dumb/stupid question but I am really a beginner and actually don't know why nothing is getting printed despite the use of the return function. I checked on various websites also but did not understand why this was happening. Thanking you in advance, Have a great day ahead!

1 Answers

Try adding a print statement to show the output:

print('Result:', search4vowels('test'))
Related