Multiplication Operator in Python (*)

posted on 03 May 2026 , updated on 03 May 2026
operators

The Multiplication Operator (*) is a versatile arithmetic operator in Python. While its primary use is to multiply numeric values, it also plays a powerful role in string and list manipulation through sequence repetition.

1. Numeric Multiplication

Standard multiplication works with integers, floats, and complex numbers. If any operand is a float, the result will always be a float.


# Multiplying Integers
print(5 * 4)       # Output: 20

# Multiplying Floats
print(2.5 * 2)     # Output: 5.0

# Complex Numbers
print((2 + 3j) * 2) # Output: (4+6j)

2. String and List Repetition

When you multiply a sequence (like a string or a list) by an integer, Python repeats that sequence multiple times. This is incredibly useful for formatting or initializing data.


# String Repetition
print("Hi! " * 3)   # Output: Hi! Hi! Hi! 

# List Repetition
zeros = [0] * 5
print(zeros)        # Output: [0, 0, 0, 0, 0]
Note: You can only multiply a sequence by an integer. Multiplying a string by a float or another string will cause an error.

3. The Power of Unpacking

In advanced Python, the * operator is used to "unpack" collections into function arguments or new lists.


numbers = [1, 2, 3]
print(*numbers)     # Output: 1 2 3 (Unpacked)

4. Common Errors to Avoid

TypeError: Attempting to multiply two strings or a string by a float.

# "Hello" * "World"  # Raises TypeError
# "Hello" * 2.5      # Raises TypeError

💡 Interesting Facts

  • Booleans: Since True is 1 and False is 0, True * 10 equals 10.
  • Zero Multiplication: Multiplying any sequence by 0 or a negative integer results in an empty sequence (e.g., "" or []).
  • Matrix Math: While * performs element-wise multiplication in some libraries, in standard Python, it follows the rules shown above.

Related Concepts

...

An article to understand the floor division operator in Python

...

An article to understand the division operator in Python

...

An article to understand the multiplication operator in Python

...

An article to understand the subtraction operator in Python

...

An article to understand the addition operator in Python

Search
Download PYTHON
Download Python on your system from python.org downloads section