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 * rightParameters & Attributes
| Name | Type | Description |
|---|---|---|
| left | number, supported sequence or custom object | Numeric factor, sequence, or repetition count. |
| right | number, supported sequence or custom object | Numeric 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)