Advertisement
nq1s788

Найти максимальное кратное 21

Oct 26th, 2024 (edited)
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.24 KB | None | 0 0
  1. #вариант с лямбдой
  2. a = [1, 6, 21, 7, 9, 11111, 42, 10, 12, 63]
  3. mx = max(a, key=lambda x: 1 if x % 21 != 0 else x)
  4. #вариант с циклом
  5. mx1 = 0
  6. for e in a:
  7.     if e % 21 == 0:
  8.         mx1 = max(mx1, e)
  9. print(mx, mx1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement