鑑於本字典自定義排列python?
dictt={2:'abc',3:'def',4:'gfi',5:'jkl',6:'mno',7:'pqrs',8:'tuv',9:'wxyz'}
我需要做一個自定義排列。
輸入中的數字會告訴您輸出的時間。
輸入也會指向正在排列的字母。例如
。 「34」將使程序返回第一個序列的第一個字母,並逐個添加第二個序列的所有3個字母。那麼它將採用第一個序列的第二個字母並加上第二個序列的所有3個字母b + d = bd b + e = be b + d = a + d = ad + e = ae a + d = af f = bf 然後第三個字母 c + d = cd c + e = ce c + f = cf 因此,當您輸入34時,如果輸入爲3個數字,它將返回ad af af bd be bf cd ce cf 。那麼如果輸入是一個數字,則輸出將是成對的3. 。那麼輸出將只是列出的相應序列。 ex: "2" would return a b c
def permuteString(numString):
array=[]
original={2:'abc',3:'def',4:'gfi',5:'jkl',6:'mno',7:'pqrs',8:'tuv',9:'wxyz'}
for a,b in original.iteritems():
print a,b
for c in b:
print c
return array
stuff=permuteString("234")
到目前爲止,我所做的只是拉字典出
什麼在「34則 「4」? –
34是什麼意思。在字典中,'3:'abc'','4:'def''。如果你輸入'34',爲什麼不輸出'dg df di eg ef ff ff fi'?我不知道你想要什麼。 – shihongzhi