185k views
5 votes
Define a function below, filter_out_strs, which takes a single argument of type list. Complete the function so that it returns a list that contains only the non-strings from the original list. It is acceptable to return an empty list if there are only strings in the original list. This question uses the filter pattern discussed in lecture.

User SharpC
by
7.1k points

1 Answer

5 votes

Answer:

Step-by-step explanation:

The following code is written in Python and is a simple function that removes all of the type String elements within the list that has been passed as an argument. Then finally, prints out the list and returns it to the user.

def filter_out_str(list):

for x in list:

if type(x) == type(" "):

list.remove(x)

print(list)

return list

Define a function below, filter_out_strs, which takes a single argument of type list-example-1
User GobSmack
by
7.8k points