I want the function to return two types of value, string and integer when counting vowels in a word. Upon invoking I’m getting only the y value, but not the x. Can you explain why is this happening?
def cnt_vow(s):
x = 0
y = ''
for char in s:
if char in 'aeuio':
y = y + char
x = x + 1
return y
return x
cnt_vow('hello')
expected: 'eo', 2
was: 'eo'
If you want both, try returning a tuple
returnalways leaves the current function, so code after it will never be executed.