python - apply Operation on multiple variables

后端 未结 6 2158
梦谈多话
梦谈多话 2021-01-27 12:26

I know that this is a rather silly question and there are similar ones already answered, but they don\'t quite fit, so... How can I perform the same operation on multiple variab

6条回答
  •  情深已故
    2021-01-27 12:54

    You can use the following generator expression:

    a, b, c = 3, 4, 5
    a, b, c = (2 * i for i in (a, b, c))
    print(a, b, c)
    # 6 8 10
    

提交回复
热议问题