Front 3 - Slice Check Repeat Concatenate

Published by serf in

Create a function that takes a string; we'll say that the front is the first three characters of the string. If the string length is less than three characters, the front is whatever is there.

Return a new string, which is the first 3 letters of the string, which will be referred to as the "Front". Along with 3 copies of it.

Examples

front3("Python") ➞ "PytPytPyt"

front3("Cucumber") ➞ "CucCucCuc"

front3("bioshock") ➞ "biobiobio"

front3("Z") ➞ "ZZZ"

Notes

Don't forget to return the result.

Watch a quick demo on how Edabit works.