From 7ba639329b2a50ece7d1c8ceeab911c333ef42e9 Mon Sep 17 00:00:00 2001 From: Rohit Barua <83600150+Rohit-beep-droid@users.noreply.github.com> Date: Sun, 23 May 2021 23:10:34 -0400 Subject: [PATCH] Update 100+ Python challenging programming exercises.txt A challenge that requires searching for vowels within a string and return a list of indexes where any vowels were spotted during the search. --- ...thon challenging programming exercises.txt | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/100+ Python challenging programming exercises.txt b/100+ Python challenging programming exercises.txt index 97af5aaf..faf36456 100644 --- a/100+ Python challenging programming exercises.txt +++ b/100+ Python challenging programming exercises.txt @@ -2371,5 +2371,28 @@ solutions=solve(numheads,numlegs) print solutions #----------------------------------------# +Level: Easy +Question: +Given a string, return a list of indexes of the letters that are vowels within the string. + +Example: +"I lovE yOU" => [0,3,5,8,9] +"ThE uNivERSE" => [2,4,6,8,11] + +Hints: Use a for loop, lower() or upper(), and append(). + +Answer: + +def find_vowels(string): + string = string.lower() + vowels = ['a','e','i','o','u'] + index_list = [] + for letter in range(0, len(string)): + if string[letter] in vowels: + index_list.append(letter) + return new_list + +find_vowels(string) +#----------------------------------------#