dxnge

9

Oct 13th, 2021
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.29 KB | None | 0 0
  1. from itertools import product
  2. a = list(map(''.join, product('ПИР', repeat=5)))
  3.  
  4. # Первый способ
  5. words = []
  6. for i in a:
  7. if i.count('П') == 1:
  8. words.append(i)
  9. print(len(words))
  10.  
  11. # Второй способ
  12. print(len(list(filter(lambda x: x.count('П') == 1, a))))
Advertisement
Add Comment
Please, Sign In to add comment