I have two list of different sizes, n and n-1. I have to concatenate two lists that look like this
list1 = ['a','b','c']
list2 = ['-','-']
They have to be concatenated to get s.th like this
str_out = 'a-b-c'
I have tried to figure out an elegant way to do this but only managed to come up with this solution
list1 = ['a','b','c']
list2 = ['-','-']
string2 = ''
for index,item in enumerate(list1):
string2 = string2 + item + list2[index-1]
print(string2)
which prints
'a-b-c-'
I am looking for a nicer implementation or how I can get rid of the final dash (-
)
EDIT: To clarify, the lists will be dynamic and list2 can contain arbitrary characters.
e.g: list2 = ['*','-']