Which function definition body is better/more likely to be used, even though they do the same task?
def count_to_first_vowel(s):
''' (str) -> str
Return the substring of s up to but not including the first vowel in s. If no vowel
is present, return s.
>>> count_to_first_vowel('hello')
'h'
>>> count_to_first_vowel('cherry')
'ch'
>>> count_to_first_vowel('xyz')
xyz
'''
substring = ''
for char in s:
if char in 'aeiouAEIOU':
return substring
substring = substring + char
return substring
or
def count_to_first_vowel(s):
''' (str) -> str
Return the substring of s up to but not including the first vowel in s. If no vowel
is present, return s.
>>> count_to_first_vowel('hello')
'h'
>>> count_to_first_vowel('cherry')
'ch'
>>> count_to_first_vowel('xyz')
xyz
'''
substring = ''
i = 0
while i < len(s) and not s in 'aeiouAEIOU':
substring = substring + s
i = i + 1
return substring
@alyphen @repository
def count_to_first_vowel(s):
''' (str) -> str
Return the substring of s up to but not including the first vowel in s. If no vowel
is present, return s.
>>> count_to_first_vowel('hello')
'h'
>>> count_to_first_vowel('cherry')
'ch'
>>> count_to_first_vowel('xyz')
xyz
'''
substring = ''
for char in s:
if char in 'aeiouAEIOU':
return substring
substring = substring + char
return substring
or
def count_to_first_vowel(s):
''' (str) -> str
Return the substring of s up to but not including the first vowel in s. If no vowel
is present, return s.
>>> count_to_first_vowel('hello')
'h'
>>> count_to_first_vowel('cherry')
'ch'
>>> count_to_first_vowel('xyz')
xyz
'''
substring = ''
i = 0
while i < len(s) and not s in 'aeiouAEIOU':
substring = substring + s
i = i + 1
return substring
@alyphen @repository