I'm trying to make code that allows me to take an input string and return how many vowels are in that input string. I had it working with built in functions, but my teacher asked me to then convert it to a user defined function and I've been having a ton of problems. I managed to fix most of them, and have spent several hours trying to search for the answer but I don't know enough terminology yet to search well.
I've tried(and have been fiddling with it for a couple of hours now but no luck.):
def count_vowels(string):
string = input('Enter string: ')
def count_vowels(i):
return i in string
if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U' ):
vowels = vowels + 1
print(count_vowels(string))
Current error is 'i' is undefined.