简体   繁体   English

在Python中获取变量的总和

[英]Taking the sum of variables in python

So I have the following code, for some reason the two variables "large" and "small" doesn't seem to add up and I don't know why. 因此,我有以下代码,由于某种原因,两个变量“大”和“小”似乎没有加起来,我也不知道为什么。 Please help me. 请帮我。

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)

Change 更改

int(large)
int(small)

large + small=y

to

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

y = large + small

应该是: y = large + small

它应该是

y = large + small

Change to this: 更改为此:

y = large+small

What is tal, btw? tal是什么,顺便说一句?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM