Answers for "how to divide list to list in python"

2

python divide every element in a list by a number

# Example usage using list comprehension:
# Say you want to divide every number in your_list by some number
your_list = [10,20,30,40,50,60,70,80,90]
new_list = [x / 10 for item in your_list]

print(new_list)
--> [1,2,3,4,5,6,7,8,9] # Each number divided by 10
Posted by: Guest on November-06-2020
-1

divide list into equal parts python

def chunks(lst, n):
    """Yield successive n-sized chunks from lst."""
    for i in range(0, len(lst), n):
        yield lst[i:i + n]
Posted by: Guest on May-12-2021

Code answers related to "how to divide list to list in python"

Python Answers by Framework

Browse Popular Code Answers by Language