Is there a quicker way to write .append more than once? Like:
combo.append(x) * 2
Instead of:
combo.append(x)
combo.append(x)
I know you cant multiply it by 2, so I'm wondering if there is a faster way?
Is there a quicker way to write .append more than once? Like:
combo.append(x) * 2
Instead of:
combo.append(x)
combo.append(x)
I know you cant multiply it by 2, so I'm wondering if there is a faster way?
You can extend instead of append:
combo.extend([x] * 2)
If combo is a local or a global, you can also use += to extend a list:
combo += [x] * 2
If combo is an class attribute, just be careful if you are referencing it on an instance, see Why does += behave unexpectedly on lists?
You might try something like combo.extend([x]*t) to append t copies of x.