""" why this 4 in second user input as 'abc'.ii know that it is counting quotes as python will take input 'abc' as " ' abc ' " hence counting 5 as length how to remove this issue for getting correct answer like other input as shown above n below"""
def get_count(words):
words=str(input('Enter:')).lower()
vowels = ['a','e','i','o','u']
v_count = 0
c_count = 0
for letter in words:
if letter in vowels:
v_count += 1
else:
c_count+=1
print("vowel : {}".format(v_count), "consonant: {}".format(c_count))
get_count(input)
Result:
Enter:aBc
vowel : 1 consonant: 2
Enter:'abc'
vowel : 1 consonant: 4- ??? why
Blockquote
Enter:abc
vowel : 1 consonant: 2
Long answer: So your string is 'abc' which is 5 characters long. python is checking:
so in the end we get: vowel : 1 consonant: 4
Short answer: your input is considered as a five character long string, and your script iterates over each element including single quotations.