← Back to challenges

Front 3 - Slice Check Repeat Concatenate

PythonMediumstringsconditions

Instructions

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 three copies of the front.

Examples

front3("Python") ➞ "PytPytPyt"

front3("Cucumber") ➞ "CucCucCuc"

front3("bioshock") ➞ "biobiobio"

Notes

Don't forget to return the result.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Fix the Error: Value vs. Reference Types