Why does itertools.permutations() return a list, instead of a string?

itertools.permutations() simply works this way. It takes an arbitrary iterable as an argument, and always returns an iterator yielding tuples. It doesn’t (and shouldn’t) special-case strings. To get a list of strings, you can always join the tuples yourself:

list(map("".join, itertools.permutations('1234')))

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)