a += [''] * (N - len(a))
or if you don’t want to change a
in place
new_a = a + [''] * (N - len(a))
you can always create a subclass of list and call the method whatever you please
class MyList(list):
def ljust(self, n, fillvalue=""):
return self + [fillvalue] * (n - len(self))
a = MyList(['1'])
b = a.ljust(5, '')