Populate range when all I have is beginning and end

If I have the following:

ABC0001-ABC0004, what would be the most efficient to output ABC0001,ABC0002,ABC003,ABC0004?

I realize there is a range function in python but at first glance it only works with numbers.


I have tried Range but it only seems to work for numbers, I am not experienced enough to do much more than that and googling is only returning stuff related to range.

>Solution :

You can solve this by creating a range and adding that to a prefix string.
The result of range can also be zfiled.
Here is a small example of how you might generate those values into a list.

prefix = "ABC"

range = range(1, 10)

output = []
for i in range:
    number = str(i).zfill(4)
    output.append(prefix + number)


Leave a Reply