That would depend on the underlying implementation of the string object, no? (If the string is implemented as a linked list it's O(n))
Anyway, it makes no practical difference in this case, since the one they labeled "O(n)" is the naive implementation that most people would write if they implemented left-pad themselves.