Solved it with index().

pos = list.index(i)
if "@" in list[pos + 1]:

Usually you split() a string into a list.

You can join() a list into a string like this:

lst = ['email@email.com','REF']
separator = ' ' # this one space will be the string between each list element
string = separator.join( lst )

I have been playing with it and didn't get index() to work, mainly because index always returns the first instance of the string if it occurs multiple times. I assume that normally it would be different values and then it wouldn't matter. But just in case the email is repeated somewhere in your lists, the only way I could get it to work was like this:

for a in range(len(list)):
     if '@' in list[a]: print list[a],
     else:
         if a < (len(list)-1):
             if '@' in list[a + 1]:
                 print list[a]
             else:
                 print list[a],
         else:
             print list[a]
This question has already been answered. Start a new discussion instead.