【发布时间】:2022-01-24 11:55:11
【问题描述】:
如何使用字典作为条件语句来改变变量的值?
例如:
a = 20
dicta = {10:3, 20:2, 30:1}
#compare using first pair as the value of a, such that:
if a=10: assign a=3
if a=20: assign a=2
if a=30: assign a=1
谢谢!
【问题讨论】:
-
那么您要做的是使用字典更改变量的值?
-
基本上是的
标签: python dictionary