Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. #Write a function called has_a_vowel. has_a_vowel should have one parameter, a string. It should return True if the string #has any vowels in it, False if it does not.
  2.  
  3. def has_a_vowel(a_str):
  4.  
  5. print("Starting...")
  6.  
  7. for letter in a_str:
  8.  
  9. print("Checking", letter)
  10.  
  11. if letter in "aeiou":
  12.  
  13. print(letter, "is a vowel, returning True")
  14.  
  15. return True
  16.  
  17. else:
  18.  
  19. print(letter, "is not a vowel, returning False")
  20.  
  21. return False
  22.  
  23. print("Done!")
  24.  
  25.  
  26.  
  27. #Below are some lines of code that will test your function. You can change the value of the variable(s) to test your #function with different inputs. If your function works correctly, this will originally print: True, then True, then False, then #False, each on its own line.
  28.  
  29. print(has_a_vowel("abba"))
  30.  
  31. print(has_a_vowel("beeswax"))
  32.  
  33. print(has_a_vowel("syzygy"))
  34.  
  35. print(has_a_vowel(""))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement