I just want to calculate the product of certain elements (whose index value + 1 is in N) of a string.
This works fine:
start = 1
end = 1000000
N = (1, 10, 100, 1000, 10000, 100000, 1000000)
product = 1
concatenated_numbers_str = ''.join([str(x) for x in range(1, end + 1)])
for n in N:
product *= int(concatenated_numbers_str[n - 1])
print(product)
But what is a better way to do this?
Thank you