Nov-29-2020, 08:14 AM
I want to get all permutations of 2 vowels
I tried:
If I run
Where has doubles gone? Seems it can only be read 1 time. Why is that? Read it and it is gone!
This gets me what I want:
from itertools import permutations doubles = permutations (['a', 'e', 'i', 'o', 'u'],2) for i in doubles: print(i)This prints all the permutations. I want to save them in a list.
I tried:
perm = ('a', 'e') perm[0] gives me 'a' perm[1] gives me 'e'Now I find, if I run:
doubles = permutations (['a', 'e', 'i', 'o', 'u'],2) for i in doubles: print(i)I see my permutations
If I run
for i in doubles: print(i)again, I get nothing. No error. Nothing.
Where has doubles gone? Seems it can only be read 1 time. Why is that? Read it and it is gone!
This gets me what I want:
doubles = permutations (['a', 'e', 'i', 'o', 'u'],2) perms = [] for i in doubles: print(i) perm = i[0] + i[1] perms.append(perm)