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,
Solution:
set1=(70, 70)
tuple(2*array(set1))
Explanation: arrays
make direct scalar multiplication possible. Hence the tuple
called set1
here is converted to an array
. I assume you wish to keep using the tuple
, hence we convert the array
back to a tuple
.
This solution is to avoid the explicit and verbose for
loop. I do not know whether it is faster or whether the exact same thing happens in both cases.