7.5.5: Contains a Vowel how do I do it?
# Ask the user for a string
word = input("Enter a string:")



# Check for lowercase vowels: a, e, i, o, or u and print
if "a" in word or "e" in word or "i" in word or "u" in word:



print "Contains a lowercase vowel!"


else;

print "Doesn't contain a lowercase vowel!"

Respuesta :

The code that checks if a user input has a vowel can be done by looping the users input and check if the users input has a vowel in it.

x = input("kindly, input your string: ")

vowels = ['a', 'e', 'i', 'o', 'u']

length = 0

for i in x:

    if i in vowels:

         length += 1

if length >= 1:

    print("Contains a lowercase vowel!")

else:

    print("Doesn't contain a lowercase vowel!")

Code explanation

The code is written in python

  • The first line of code ask the user for an input.
  • The vowels are stored ina variable called "vowels".
  • The variable "length" is initialise to zero.
  • Then, we loop through the value in the users input.
  • If the users input contain any vowel the length is incremented by 1.
  • Finally if the length is greater or equals to 1 we print a message "Contains a lowercase vowel"
  • Else we print "Doesn't contain a lowercase vowel!"

learn more on python code here: https://brainly.com/question/15114317

Ver imagen vintechnology
Ver imagen vintechnology