I am trying to practice for my upcoming practice test on programming, so he looked online for examples and came across this.
"Write a translate () function that translates the text into" rövarspråket "(Swedish for" predatory language "), ie doubles each consonant and puts an" o "between them. For example, translate (" it's fun ") should return a string "tothohisos isos fofunon".
I don’t know why, but I struggle a lot with this. So simple, but still hard for me. Here is what I tried
def translate(n):
consonant="bcdfghjklmnpqrstvwxyzBCDFGHJKLMNPQRSTVWXYZ"
for letters in n:
if letters in consonant:
return (letters+"O"+letters)
else:
return("Vowel")
Sorry if my coding is super-amateur. Just trying to find out: /
source
share