← Back to challenges

Modifying the Last Character

PythonMediumstringslanguage_fundamentals

Instructions

Create a function which makes the last character of a string repeat n number of times.

Examples

modify_last("Hello", 3) ➞ "Hellooo"

modify_last("hey", 6) ➞ "heyyyyyy"

modify_last("excuse me what?", 5) ➞ "excuse me what?????"

Notes

  • Test will include numbers and punctuation.
  • Make sure the code is not case sensitive.
python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Equality Check