MasankoX25 MasankoX25 - 23 days ago 11
Python Question

i would like an error check to ensure that the string has vowels input

from collections import Counter
Astring = input("Enter a word or sentence: ")
vowel = 'a' 'e' 'i' 'o' 'u'
Astring = Counter(c for c in Astring.lower() if c in vowel)
min_values = {mainv: Astring[mainv] for mainv in Astring if Astring[mainv] == min(Astring.values())}

if vowel not in Astring:
print ("your text must contain vowels")

else:


print("The least occuring vowel is:")
for m in min_values:
print("{vowel} with {occ} occurences.".format(vowel=m, occ=min_values[m]))


I would like my code to output the lowest occurring vowel on top of this i would like an error check to ensure that the string has vowels input in to it

Answer

Lots of issues with formatting and syntax in you example, but the following works and is reasonably close to how you were attempting to do it:

from collections import Counter

VOWELS = ('a', 'e', 'i', 'o', 'u')

string = raw_input("Enter a word or sentence: ")
if not any(True for vowel in VOWELS if vowel in string.lower()):
    print("your text must contain vowels")
else:
    print("The least occuring vowel is: {}".format(Counter(c for c in string.lower() if c in VOWELS).most_common()[-1]))