#suppose
list = [1, ‘2’, W, a b c, ‘man’]
#output should be : [ ‘2’, ‘man’]
#suppose
list = [1, ‘2’, W, a b c, ‘man’]
#output should be : [ ‘2’, ‘man’]
Hi - Yes, you can certainly filter the strings or any other types from a list.
But first, please check your list entries, it includes W, a b c… It is not correct to add entries like this.
It will give syntax errors when you execute. However, below is the code to check for strings in a list.
list = [1, '2', 'man', 22, 1.2]
for item in list:
if type(item) is str:
print(item)
This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.