-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove.py
34 lines (27 loc) · 842 Bytes
/
move.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import unittest
# Weekly Challenge June 18, 2024
# Change Every Letter to the Next Letter
# Write a function that changes every letter to the next letter:
# "a" becomes "b"
# "b" becomes "c"
# "d" becomes "e"
# and so on ...
#
# Notes
# There will be no z's in the tests.
def move(word: str) -> str:
"""
Changes every letter of the word to the next letter.
:param word: The word to change.
:returns: The word with its letters moved.
"""
return "".join(chr(ord(letter) + 1) for letter in word)
class MoveTest(unittest.TestCase):
def test_move(self) -> None:
self.assertEqual(move("hello"), "ifmmp")
self.assertEqual(move("bye"), "czf")
self.assertEqual(move("welcome"), "xfmdpnf")
if __name__ == "__main__":
unittest.main()