2015-07-21 47 views
0

所以我有下面的代碼,出於某種原因,兩個變量「大」和「小」似乎並沒有加起來,我不知道爲什麼。請幫幫我。考慮python變量的總和

n = int(input("number:")) 

x = map(int, str(n)) 
x = [int(x) for x in tal] 

x.sort(reverse=True) 
large = "".join(map(str, x)) 

x.sort() 
small = "".join(map(str, x)) 

int(large) 
int(small) 

large + small=y 

print(y) 
+0

我認爲應該是'y = large + small'?什麼是'tal',爲什麼你使用'int(str(int(n)))' – Chaker

+0

你得到的錯誤在你的程序中有很多錯誤 – The6thSense

+1

你在列表理解中使用的變量'tal'是什麼? –

回答

1

它應該是:y = large + small

3

變化

int(large) 
int(small) 

large + small=y 

large = int(large) 
small = int(small) 

y = large + small 
0

應該

y = large + small 
0

更改爲:

y = large+small 

什麼是tal,btw?