mirror of
https://github.com/freeCodeCamp/freeCodeCamp.git
synced 2026-05-28 18:26:54 +00:00
1.7 KiB
1.7 KiB
id, title, challengeType, dashedName
| id | title | challengeType | dashedName |
|---|---|---|---|
| 69a890af247de743333bd4ce | Challenge 225: No Consecutive Repeats | 29 | challenge-225 |
--description--
Given a string, determine if it has no repeating characters.
- A string has no repeats if it does not have the same character two or more times in a row.
--hints--
has_no_repeats("hi world") should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("hi world"), True)`)
}})
has_no_repeats("hello world") should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("hello world"), False)`)
}})
has_no_repeats("abcdefghijklmnopqrstuvwxyz") should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("abcdefghijklmnopqrstuvwxyz"), True)`)
}})
has_no_repeats("freeCodeCamp") should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("freeCodeCamp"), False)`)
}})
has_no_repeats("The quick brown fox jumped over the lazy dog.") should return True.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("The quick brown fox jumped over the lazy dog."), True)`)
}})
has_no_repeats("Mississippi") should return False.
({test: () => { runPython(`
from unittest import TestCase
TestCase().assertIs(has_no_repeats("Mississippi"), False)`)
}})
--seed--
--seed-contents--
def has_no_repeats(s):
return s
--solutions--
def has_no_repeats(s):
for i in range(1, len(s)):
if s[i] == s[i-1]:
return False
return True