整数のいくつかのタプルといくつかの整数で構成されるタプルがあります.今、((1, 2), 3, (4, 5), 6)
そこからすべての整数が必要です。私が書いた:
def get_all_items(iterable):
t = []
for each in iterable:
if type(each) == int:
t.append(each)
else:
t.extend(each)
return tuple(t)
わたしにはできる。これを行うより良い方法はありますか?