October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk1 min

How to Divide Each Element in a List by a Number in Python

Use a list comprehension to divide every item in a Python list. Understand true division, floor division, map, and NumPy array arithmetic.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use a list comprehension: [value / divisor for value in values]. It divides each item with Python’s true-division operator and returns a new list, leaving the original list unchanged.

Divide every list element with a list comprehension

For an ordinary Python list, no extra package is needed:

As an Amazon Associate I earn from qualifying purchases.

values = [10, 20, 30]
divisor = 5
result = [value / divisor for value in values]

print(result)  # [2.0, 4.0, 6.0]
print(values)  # [10, 20, 30]

The expression loops over values, divides each value by divisor, and collects the results into a new list. To bind the result back to the same variable name, assign it explicitly: values = [value / divisor for value in values].

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Choose between true division and floor division

Python’s / operator performs true division, so a result can include a fractional part. Use // when you specifically want floor division, which rounds the quotient down toward negative infinity.

values = [5, 7, 9]
divisor = 2

ordinary = [x / divisor for x in values]  # [2.5, 3.5, 4.5]
floored = [x // divisor for x in values]  # [2, 3, 4]

For negative values, floor division is not the same as truncating toward zero: for example, -5 // 2 is -3. See Python’s operator reference for the distinction between true division and floor division.

When to use map

map applies a function to each item, but returns an iterator rather than a list. Wrap it in list() if you need a list immediately:

values = [10, 20, 30]
divisor = 5
result = list(map(lambda x: x / divisor, values))

For a simple arithmetic operation, the list comprehension is usually easier to read. map can be a natural choice when you already have a named function to apply. Python documents map and list comprehensions in its built-in functions reference.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

When NumPy makes sense

If your data is already a NumPy array, dividing it by a scalar operates element by element and keeps the result as an array:

import numpy as np

values = np.array([10, 20, 30])
result = values / 5

NumPy’s quickstart guide covers element-wise array operations. For a short built-in Python list, a comprehension is sufficient; NumPy is useful when the broader task calls for array computing.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Windows Errors? Fix Them Before They SpreadFree repair scan
Outdated Drivers Are Slowing You DownFree scan - exact matches

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.