Answer the question
In order to leave comments, you need to log in
How to sort two numbers in a list?
There is a code where I tried to implement it myself:
hours = ['0', '3', '2', '7']
minutes = ['23', '9', '16', '10']
time = ''
for i, n in enumerate(sorted(zip(minutes, hours), key=lambda n: int(n[0:2]), reverse=True), 1):
time += f"{i}. Время: {n[1]}ч {n[0]}м\n"
print(time)
Answer the question
In order to leave comments, you need to log in
import datetime
for i, n in enumerate(sorted(zip(hours, minutes), key=lambda n: datetime.time(int(n[0]), int(n[1])), reverse=True)):
print(f"{i}. Время: {n[0]}ч {n[1]}м")
0. Время: 7ч 10м
1. Время: 3ч 9м
2. Время: 2ч 16м
3. Время: 0ч 23м
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question