Hi there,
I have a mixed list containing strings, integers, strings with numbers both prefix and suffix and mixed case strings as follow:
mixedlist = ["cake", 12, "cakecar", "cAKe", "orange", "apple", "1cake", "cake1"]
I'm trying to filter the list for any element containing "cake" so I get a new list that looks something like this:
newlist = ["cake", "cakecar", "cAKe", "1cake", "cake1"]
So my approach was to:
convert each element in the list to a string (avoiding any integers) using:
stringlist = [str(x) for x in mixedlist]
and then using x.lower() to ignore case.
then for loop'in through the list looking for any element containing "cake"
and finally using newlist.append(x) to append filtered elements to new list
problem is i cant filter out an element that contains "cake" were its with a number i.e. "1cake" or "cake1" nor an element containing cake with anything else i.e. "cakecar"
Any help would be appreciated, cheers!