Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from itertools import product
- a = list(map(''.join, product('ABCX', repeat=5)))
- # Первый способ
- words = []
- for i in a:
- if i.count('X') == 1 and i[-1] == 'X' or i.count('X') == 0:
- words.append(i)
- print(len(words))
- # Второй способ
- print(len(list(filter(lambda x: x.count('X') == 1 and x[-1] == 'X' or x.count('X') == 0, a))))
Advertisement
Add Comment
Please, Sign In to add comment