Hi, I want to convert a list using python. I have a list of list like this: Read more
You can use Counter if you want to do multiple count of the list from collections import Counter list = ['Jones','Adams','Frank','John','Lopez','Jones','Smith','Ivan','Julian','Carlos','Adams','Frank','Jones','John','Ivan'] print(Counter(list)) Result: Counter({'Jones': 3, 'Adams': 2, 'Frank': 2, 'JRead more
You can use Counter if you want to do multiple count of the list
1 2 3 4 | from collections import Counter list = ['Jones','Adams','Frank','John','Lopez','Jones','Smith','Ivan','Julian','Carlos','Adams','Frank','Jones','John','Ivan'] print(Counter(list)) |
Result:
1 2 | Counter({'Jones': 3, 'Adams': 2, 'Frank': 2, 'John': 2, 'Ivan': 2, 'Lopez': 1, 'Smith': 1, 'Julian': 1, 'Carlos': 1}) |
See less
Hello this code may help you: def flatten_list(original_List): flat_list = [] for sub_list in original_List: for element in sub_list: flat_list.append(element) return flat_list #test original_List=[['a', 'b', 'c', 'd','e'], ['f', 'g', 'h', 'i'], ['j', 'k', 'l'], ['m', 'n', 'o']] print('original listRead more
Hello
this code may help you:
See less