Python Itertools permutations only letters and numbers

后端 未结 6 1091
無奈伤痛
無奈伤痛 2021-01-13 12:42

I need to get only the permutations that have letters and numbers (The permutation can not be. \"A, B, C, D\" I need it like this: \"A, B, C, 1\")

In short, the perm

6条回答
  •  野的像风
    2021-01-13 13:27

    Quite a naive solution..

    (x
        for x in itertools.combinations([0,1,2,3,4,'a','b','c','d'], 4)
        if not all(c.isalpha() for c in x) and not all(c.isdigit() for c in x))
    

提交回复
热议问题