Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Loop, skip and step solution in Clear category for Bird Language by Gazump
VOWELS = 'aeiouy'
CONSONANTS = 'bcdfghjklmnpqrstvwxz'
def translation(phrase):
"""Returns string
- counts through phrase using index i
- if vowel, skips next 3 characters
- if consonant, skips next character
- otherwise, it just goes to next character
- records the character it falls on each loop through
"""
i = 0
output = ''
while i < len(phrase):
char = phrase[i]
output += char
if char in VOWELS:
i += 3
elif char in CONSONANTS :
i += 2
else:
i += 1
return output
if __name__ == '__main__':
print("Example:")
print(translate("hieeelalaooo"))
#These "asserts" using only for self-checking and not necessary for auto-testing
assert translation("hieeelalaooo") == "hello", "Hi!"
assert translation("hoooowe yyyooouuu duoooiiine") == "how you doin", "Joey?"
assert translation("aaa bo cy da eee fe") == "a b c d e f", "Alphabet"
assert translation("sooooso aaaaaaaaa") == "sos aaa", "Mayday, mayday"
print("Coding complete? Click 'Check' to review your tests and earn cool rewards!")
Nov. 30, 2019