Multiplying a tuple by a scalar

后端 未结 12 905
忘了有多久
忘了有多久 2020-12-14 14:48

I have the following code:

print(img.size)
print(10 * img.size)

This will print:

(70, 70)
(70, 70, 70, 70, 70, 70, 70, 70,          


        
12条回答
  •  长情又很酷
    2020-12-14 14:57

    You can try something like this:

    print [10 * s for s in img.size]
    

    It will give you a new list with all the elements you have in the tuple multiplied by 10

提交回复
热议问题