【发布时间】:2020-04-30 09:19:50
【问题描述】:
这一定是一个简单的问题,但我就是找不到正确的解决方案。
所以,我有 4 个变量。
number1 = 10
number2 = 14
number3 = 6
number4 = 11
我需要让程序获取所有变量,比较它们,然后打印出包括变量名在内的最高数字。 E.G
"variable 'number4' has the highest number with a value of: '11'
到目前为止,互联网上没有任何帮助,但我无法想象它有那么难。 我可能在这里错过了一个明显的功能或其他东西
【问题讨论】:
-
是的,但使用 max() 只会返回“4”。我还需要它来记住变量名。示例:“变量 w = 4 作为最大值”
-
这能回答你的问题吗? Getting the name of a variable as a string
标签: python-3.x integer compare