Operators

* — Multiplication and sequence repetition

Multiplies numeric operands; with a supported sequence and an integer-like repetition count, it repeats the sequence. Negative counts produce empty sequences. Repetition does not clone referenced elements, so repeated nested mutable values can alias. Custom classes can implement __mul__ or __rmul__. This operator shares precedence with division and matrix multiplication, and binds more tightly than addition.

Formal Syntax & Structure

python syntaxpython
left * right

Parameters & Attributes

NameTypeDescription
leftnumber, supported sequence or custom objectNumeric factor, sequence, or repetition count.
rightnumber, supported sequence or custom objectNumeric factor or corresponding repetition count or sequence.

Return Value

object

Result selected by the operand types and their operation implementations.

Working Example

Example Snippetpython
print(7 * 6)print("ha" * 3)rows = [[]] * 2rows[0].append(1)print(rows)
Python Reference