Question: In python, can anyone help me to debug the 2 function code I have def partition(s): Returns a tuple containing the vowels in s
In python, can anyone help me to debug the 2 function code I have
def partition(s): """ Returns a tuple containing the vowels in s and the consonants in s. Vowels are defined to be the letters 'a', 'e', 'i', 'o', and 'u'. This function returns a tuple of two elements, the vowels in s and the the consonants in s. The vowels and consonants are presented in the same order that they occur in s, duplicates included. Examples: partition('hello') returns ('eo','hll') partition('superstar') returns ('uea','sprstr') partition('scary') returns ('a','scry') partition('a') returns ('a','') partition('k') returns ('','k') Parameter s: The string to partition Precondition: s is nonempty string of only lowercase letters """
#first code I have
# TWO accumulators left = '' right = '' pos = 0 limit = 10 letter = len(s) while pos <= len(s): if limit > 0: limit = limit -1 else: limit = limit
return limit
# 2nd code I have
while pos < len(s): letter = s[pos] if letter in 'aeiou': left = left+letter else: right = right+letter pos = pos+1
return (left,right)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
