You can use itertools.product for this. It returns a generator of sequences of fixed length.
As you order your strings first by length and then lexicographically, you may use something like this
import itertools
for l in range(1, 5):
for seq in itertools.product("abc", repeat=l):
print("".join(seq))
3
solved Find All Possible Fixed Size String Python