Uh... I may be barking at the moon here but your if statements for the image selection are not correct. Unless I'm very much mistaken, you can't do a
if 2<x<10 statement and get it to work correctly in the manner you want it to. The proper format is
if 2<x and x<10, because the term of 2<x returns either a zero or one, which will then be tested against the <10 value. Both in moving left and moving right, you have this mixed comparison, which could explain your failing animation.
S.
Any truly great code should be indisguishable from magic.