TypeError: can't multiply sequence by non-int of type 'float' (Python) — how to fix
Traceback (most recent call last):
File "app.py", line 3, in <module>
total = price * 1.15
TypeError: can't multiply sequence by non-int of type 'float'
Quick fix: Convert the value to a number first: price = float(input("Price: ")). For element-wise math on a list use a comprehension [x * 1.15 for x in values] or a NumPy array np.array(values) * 1.15. For pandas columns, convert with pd.to_numeric(df["col"]).
What it means
In Python, * on a sequence means repeat: "ab" * 3 is "ababab" and [0] * 4 is [0, 0, 0, 0]. Repetition only works with an integer. When the right-hand side is a float, Python can't repeat something 1.15 times and raises this error.
So one operand is a str, list or tuple when you expected a number. Check with:
print(type(price), repr(price))
Variants: can't multiply sequence by non-int of type 'str' (both sides are strings) and ... of type 'list'.
Cause 1: input() or file data is a string
input(), sys.argv, CSV readers and .read() always return strings.
price = input("Price: ") # "10.5" (str)
total = price * 1.15 # TypeError
Fix: convert at the point where the data enters your program.
price = float(input("Price: "))
total = price * 1.15
If the input might not be a number, catch ValueError:
try:
price = float(raw)
except ValueError:
print(f"Not a number: {raw!r}")
Cause 2: multiplying a whole list
Lists do not do element-wise math.
values = [1.0, 2.5, 4.0]
scaled = values * 0.5 # TypeError
Fix with a comprehension:
scaled = [v * 0.5 for v in values]
Or with NumPy, which does vectorised arithmetic:
import numpy as np
scaled = np.array(values) * 0.5
Cause 3: a pandas column stored as text
If a CSV column has stray characters ("1,200", "$5", blanks), pandas loads it with dtype object (strings). Multiplying a single cell then fails, and multiplying the column gives odd results or errors.
df["price"] = pd.to_numeric(df["price"].str.replace(",", ""), errors="coerce")
df["total"] = df["price"] * 1.15
errors="coerce" turns unparseable values into NaN so you can find them with df[df["price"].isna()].
Cause 4: a tuple from a function or a trailing comma
A trailing comma creates a tuple:
rate = 0.2, # (0.2,) <- tuple, not float
total = 49.9 * rate # TypeError
and a function that returns several values returns a tuple:
def get_rate():
return 0.2, "EUR"
amount = 99.5 * get_rate() # float * tuple -> TypeError
Remove the comma, or unpack: rate, currency = get_rate().
Cause 5: you really wanted repetition
If you meant to repeat a string a computed number of times, the count must be an int:
line = "-" * int(width * 0.5)
Last updated 2026-11-29.