← Back to challenges

Find First Character That Repeats

PythonHardstringslogicloops

Instructions

Create a function that takes a string and returns the first character that repeats. If there is no repeat of a character, then return "-1".

Examples

first_repeat("legolas") ➞ "l"

first_repeat("Gandalf") ➞ "a"

first_repeat("Balrog") ➞ "-1"

first_repeat("Isildur") ➞ "-1"

Notes

Tests are case sensitive.

python3
Loading editor…
to run
Walks through the solution with reasoning and edge cases.
Next: Making Change