Create an "encode_rot()" function in Python 3 to encode any given strings using the ROT algorithm. The input should contain a key and a string of text. The key can be any integer, both negative and positive (-12: turn left 12 positions, 36: turn right 36 positions). Only alphabet letters are encoded.
The following two lines of your code will generate an output of "Ocejkpg ECP ngctp 2 !!!".
clear_text = "Machine CAN learn 2 !!!"
encode_rot(clear_text, 28)