From collections import counter c = counte. Don't use quotes on the command line 1 don't use type=list, as it will return a list of lists this happens because under the hood argparse uses the value of type to coerce each individual given argument you your chosen type, not the aggregate of all arguments You can use type=int (or whatever) to get a list of ints (or whatever) List_of_values doesn't have to be a list It can be set, tuple, dictionary, numpy array, pandas series, generator, range etc And isin() and query() will still work.
In c# if i have a list of type bool What is the fastest way to determine if the list contains a true value I don’t need to know how many or where the true value is I just need to know if one e. A list of lists would essentially represent a tree structure, where each branch would constitute the same type as its parent, and its leaf nodes would represent values. The first way works for a list or a string
Other than that i think the only difference is speed It looks like it's a little faster the first way Try it yourself with timeit.timeit () or preferably timeit.repeat (). The first, [:], is creating a slice (normally often used for getting just part of a list), which happens to contain the entire list, and thus is effectively a copy of the list The second, list(), is using the actual list type constructor to create a new list which has contents equal to the first list. If your list of lists comes from a nested list comprehension, the problem can be solved more simply/directly by fixing the comprehension
Please see how can i get a flat result from a list comprehension instead of a nested list? The most popular solutions here generally only flatten one level of the nested list See flatten an irregular (arbitrarily nested) list of lists for solutions that. 1538 first declare your list properly, separated by commas You can get the unique values by converting the list to a set. The reason you're getting the unhashable type