Docsity

X65087 Walking vowels, Ejercicios de Informática

Toggle sidebar
bg1
Dessign the function vocales_andarinas(w) which, given a str w in lowercase,
rewrites it rotating by one the vowels.!
That is,!
where there is an a put e!
where there is an e put i!
...!
where there is an u put a
def vocales_andarinas(w):
'''
>>> vocales_andarinas("patata")
'petete'
>>> vocales_andarinas("aeiou")
'eioua'
>>> vocales_andarinas("mi mama me mima")
'mo meme mi mome'
'''
res = ''
for x in w:
if x == 'a': res += 'e'
if x == 'e': res += 'i'
if x == 'i': res += 'o'
if x == 'o': res += 'u'
if x == 'u': res += 'a'
if x not in 'aeiou': res += x
return res
if __name__ == '__main__':
import doctest
print(doctest.testmod())

Vista previa parcial del texto

¡Descarga X65087 Walking vowels y más Ejercicios en PDF de Informática solo en Docsity!

Dessign the function vocales_andarinas(w) which, given a str w in lowercase,

rewrites it rotating by one the vowels.

That is,

where there is an a put e

where there is an e put i

where there is an u put a

def vocales_andarinas(w): _'''

vocales_andarinas("patata") 'petete' vocales_andarinas("aeiou") 'eioua' vocales_andarinas("mi mama me mima") 'mo meme mi mome' '''_ res = '' for x in w: if x == 'a': res += 'e' if x == 'e': res += 'i' if x == 'i': res += 'o' if x == 'o': res += 'u' if x == 'u': res += 'a' if x not in 'aeiou': res += x return res if name == 'main': import doctest print(doctest.testmod())