You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.4 KiB

Shout

This function take a text and shouts it LOUD. It repeats the vowels for a specified number of times.

In [1]:
def shout(text: str, volume: int = 5) -> str:
    """Repeat the vowels in a string for a specified number of times"""
    shouted_text = ''
    for c in text:
        character = c
        if c.lower() in ['a','e','i','o','u','y']:
            character = character * volume
        shouted_text = shouted_text + character
    return shouted_text

Snake on a sbake

Examples

In [2]:
shout('help')
Out[2]:
'heeeeelp'

The first parameter is the text you want to shout. It can be anything, like a terrorized cry or a drunk song at 4am outside the pub. If you want to scream louder you can specify a second parameter for the volume. This is a number and by default is 5. It has to be positive but there are no limits to it.

In [3]:
shout('HELP', 10)
Out[3]:
'HEEEEEEEEEELP'

You see, this is very a dangerous situation.

In [4]:
shout('OMG HELP', 0)
Out[4]:
'MG HLP'

A muted scream