Could you please help me with writing a function, which receives a character char (ie., a string of infinite length), and an integer rotation. My function should return a new string of infinite length, the resulting of rotating char by rotation number of places to the right. My output for this code should be like this:
Type a message:
Hey, you!
Rotate by:
5
Mjd, dtz!
So far this is what I have:
def rotate_character(char, rot):
move = 97 if char.islower() else 65
return chr((ord(char) + rot - move) % 26 + move)
char = input('Type a message: ')
rot = int(input('Rotate by: '))
print(rotate_character(char, rot))
and this is the error message I get:
TypeError: ord() expected a character, but string of length 9 found on line 3