TypeError: sequence item 0: expected str instance, tuple found

from itertools import permutations 

def solution(numbers):
    for i in range(1,len(numbers)+1):
        a = list(permutations(numbers,i))
        print(a)
        
 # 	a = [('1',), ('7',)] , 	[('1', '7'), ('7', '1')]

join을 할려고 하면! 
print("".join(a))
# TypeError: sequence item 0: expected str instance, tuple found 

왜냐하면 string.join connects elements inside list of strings, not tuples
즉, join을 할 때 list안에 요소들은 string이어야 한다. 여기서는 tuple이다.
따라서,

  a = list(permutations(numbers,i))
 per = list(map("".join, a))   

좋은 웹페이지 즐겨찾기