If the channels named 0 to 9 are the only channels in the image, you can iterate on a copy of the channels list:
image.channels gives the list of channels in the image.
image.channels[:] creates a copy of that list (since you delete the channel at the end of the loop, you need to work on a copy of the list)
channel.name gives the name of the channel as string
Code:
for channel in image.channels[:]:
pdb.gimp_image_select_item(image, CHANNEL_OP_REPLACE, channel)
layer_add = pdb.gimp_layer_new_from_drawable(layer, image)
pdb.gimp_image_insert_layer(image, layer_add, None, 0)
pdb.gimp_item_set_name(layer_add, channel.name)
mask = pdb.gimp_layer_create_mask(layer_add, ADD_MASK_SELECTION)
pdb.gimp_layer_add_mask(layer_add, mask)
pdb.gimp_image_remove_channel(image, channel)
image.channels[:] creates a copy of that list (since you delete the channel at the end of the loop, you need to work on a copy of the list)
channel.name gives the name of the channel as string