mercredi 9 novembre 2016

Python 3.5, Finding user inputted values in a set and displaying them

from collections import Counter

inp = input("Please enter some text: ")
vowels = set("aeiouAEIOU")

if inp in vowels:
    res = Counter(c for c in inp if c in vowels)
    print (res.most_common())

elif inp not in vowels:
    print("No vowels entered.")

Code is meant to output vowels if any are found in the users input or if there are none, print a message. Currently the code does not work if more than one vowel in inputted by the user as it print the line "No vowels entered". How can this fault be corrected.

Aucun commentaire:

Enregistrer un commentaire