Saturday, 15 August 2015

Iterating over a list of lists and ignoring strings if they appear inside a larger string - Python -


I want to iterate on the list of lists, and check whether there is any other string in any of the other conditions In the second position if there are other telegrams, then they should be left, then I want to return only the strings back to the first position as a large string. It requires working with a string in a list.

This description is terrible, so this is an example.

  record = [['436', 'University' ['123', 'University Hospital'], ['956', 'School']]  

I want here that the output is:

  '123 956'  

The reason is "university" is in "university hospital" So I do not need the number associated with it.

I have no luck with the solution, and this is the best I can do:

  final_string = '' inst inst record for: if inst [1 ] Not in the record: last_string = final_string + inst [0] + ''  

This gives all the strings in the first position, i.e.

  '436 123 956 ' 

This can work.

 for  I in the Record (Record) for Xx = EnquĂȘn = Trophy (x [i] 1 in x [1] record [i + 1:]): If INR [1] in RE: Append = breaks fault if add: last_string = to improve some performance, you're just looking for words already  cache , but this is another topic! 

Hope it helps!


No comments:

Post a Comment