diff options
Diffstat (limited to 'challenge-282/packy-anderson/python/ch-2.py')
| -rwxr-xr-x | challenge-282/packy-anderson/python/ch-2.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/challenge-282/packy-anderson/python/ch-2.py b/challenge-282/packy-anderson/python/ch-2.py new file mode 100755 index 0000000000..fc7936433c --- /dev/null +++ b/challenge-282/packy-anderson/python/ch-2.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python + +def keyChanges(strVal): + chars = list(strVal) + char = chars.pop(0) + changes = 0 + for next in chars: + if char.lower() != next.lower(): + changes += 1 + char = next + return changes + +def solution(strVal): + print(f"Input: $str = '{strVal}'") + print(f"Output: {keyChanges(strVal)}") + +print('Example 1:') +solution("pPeERrLl") + +print('\nExample 2:') +solution("rRr") + +print('\nExample 3:') +solution("GoO") |
