Код: Выделить всё
my_list = ['10 apples', '4 dogs', '9 cats']
Код: Выделить всё
headers = [words.replace(' ', '_') for words in my_list]
numbers= [nums.split()[0] for nums in my_list]
Код: Выделить всё
# Create lists
headers = [my_list.replace(' ', '_') for words in my_list]
numbers= [my_list.split()[0] for nums in my_list]
# Sort Lists
headers.sort(reverse = True)
numbers.sort(reverse = True)
Подробнее здесь: https://stackoverflow.com/questions/731 ... prehension
Мобильная версия