0

How to filter strings from a list of values?

values = [3, '2', '6'] var1 = [] for i in values: if type(i) == str: var1.append(i) #it works # but what if # the case is : values = [ none, W, e a t, '5', '0', 3]

30th Jul 2018, 1:15 PM
Tincture
2 Respuestas
+ 1
W is not a string But 'W' is a string without quotes it is considered as a variable not string hence the list values is not valid
28th Aug 2018, 3:43 AM
Aravind Shetty
Aravind Shetty - avatar
+ 1
Should work too
30th Jul 2018, 1:18 PM
Tim
Tim - avatar