input - How to remove empty separators from read files in Python? -


here input file sample (z.txt)

>qrst abcde--  6  6 35 25 10 >qqqq abbde--  7  7 28 29  2 

i store alpha , numeric in separate lists. here output of numerics list #output : ['', '6', '', '6', '35', '25', '10'] ['', '7', '', '7', '28', '29', '', '2']

the output has space when there single digits because of way file has been created. there anyway rid of '' (empty spaces)?

you can take advantage of filter none function that:

numbers = ['', '7', '', '7', '28', '29', '', '2'] numbers = filter(none, numbers) print numbers 

see in action here: https://eval.in/640707


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -