>>> test_list = [4, 5, 2, 6, 7, 8, 10] >>> n = 5 >>> res = test_list[-n:] >>> res [2, 6, 7, 8, 10] >>>
message = iloveyouchina #get last x words #for example x = 3 print(message[-3:]