Hello,
I'm new to python and would really appreciate your help.

for j in range(0,13):
    if files.startswith(name + ' ' + str(j)):
        do stuff

This works for j= 0-9, but for j = 10, 11, 12 etc, it just sees the first numerical digit (eg.1).
I assume I don't want j to be a string, but if I try:
if files.startswith(name + ' ' + j)
then I get error message "cannot concatenate 'str' and 'int' objects.

Thanks for your help!
fml

usually you would add separator like _ between parts of name or use fixed number of digits. Otherwise you ned to code parsing function, use regular expression to find numbers (re.findall(r'\d+', filename))

Also iterating in opposite direction would help.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.