String manipulation in list of lists in Python -


I have a list that contains hundreds of sub-lists. The list is from a database table and the sub-lists are the rows of that table, so sub-lists all have the same entries, and the entries are in the same format as in the related sub-lists. Here's an example:

  person = [['2014-2-20', 'Ivan', 'Jones',' Moscow ', '21 -0049', 'Green'], ['2014-1-12', 'Mike', 'Dyson', 'Glasgow', '9 / 30-6', 'Green']] ... etc.  

How to Can I edit all 5th fields to remove any '-' and '/' signals?

After removing unwanted signals, how can I create a new list containing all the information, where 1) The second last figure of 5th position is 4, and 2) the color of the 6 field is 'blue' is?

The answer list has an understanding.

  person = [p [: 4] + [p] [4] .valve ('-', ''). [P] = [P] for people in P [4] [- 2] == '4'] [pblue = [People's P For p if p [5] == 'blue']  

Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -