You can use mod 3 (i%3) to find out which index value you need to concat with. Here I am doing it using mod 3 as the length of formats is 3.
Here's the implementation.
my_list = range(11, 17)
formats = ['#', '$', '%']
mystring = ''.join(str(i)+formats[(i+1)%3] for i in my_list)[:-1]
print (mystring)
Since we are using join, it concats the last range number as well. So we need to exclude the last position. To do that i am using [:-1]
Output for this is:
11#12$13%14#15$16
If you want to make it generic, you can do this:
mystring = ''.join(str(j)+formats[i%len(formats)] for i,j in enumerate(my_list))[:-1]
Here's the results for the following ranges:
formats = ['#', '$', '%']
my_list = range(11, 25)
11#12$13%14#15$16%17#18$19%20#21$22%23#24
formats = ['#', '$', '%']
my_list = range(12, 25)
12#13$14%15#16$17%18#19$20%21#22$23%24
formats = ['#', '$', '%']
my_list = range(13, 25)
13#14$15%16#17$18%19#20$21%22#23$24
formats = ['#', '$', '%']
my_list = range(14, 25)
14#15$16%17#18$19%20#21$22%23#24
formats = ['#', '$', '%']
my_list = range(15, 25)
15#16$17%18#19$20%21#22$23%24
my_list = range(11, 25)
formats = ['#', '$', '%', '&','@']
11#12$13%14&15@16#17$18%19&20@21#22$23%24
my_list = range(12, 25)
formats = ['#', '$', '%', '&']
12#13$14%15&16#17$18%19&20#21$22%23&24
Let me know if the generic code fails on any condition.