I am trying to make a program that detects how many vowels are in a word you type. Here's my source code (I have multiple codes):
a = input("word - ").lower()
for i in range(1, len(a)+1):
if a[str(i)] == "a" or "e" or "i" or "o" or "u":
print("ok")
else:
print("no")`
And I get the error:
TypeError: string indices must be integers
The second one:
a = input("word - ").lower()
for letter in a:
if letter == "a" or "e" or "i" or "o" or "u":
value = 0
value = value + 1
print(value)
Also gives me an error:
TypeError: string indices must be integers
The third one is a little bit more complex:
a = input("rec - ").lower()
for i in range(1, len(a)+1):
if a[str(i)] == "a":
print("yes a")
elif a[str(i)] == "e":
print("yes e")
elif a[str(i)] == "i":
print("yes i")
elif a[str(i)] == "o":
print("yes o")
elif a[str(i)] == "u":
print("yes u")
I am working on Python 3.6.1 on Repl.it
You can check out the full source code at my profile.
I appreciate your help. Thank you!