loops - Using Operations on a List in Python and Aggregating Results in New List -


i have list of numbers, of need divided same number. can this, no problem, how create new list featuring these new quotients?

i have tried:

for n in numbers:     newnumbers = []     newnumbers.append(n/649.00) 

but gives me 1 number, quotient of last number in list, back.

instead of loop can use list comprehension (see https://docs.python.org/3/tutorial/datastructures.html#list-comprehensions):

newnumbers = [n/649.00 n in numbers] 

Comments

Popular posts from this blog

css - SVG using textPath a symbol not rendering in Firefox -

Java 8 + Maven Javadoc plugin: Error fetching URL -

order - Notification for user in user account opencart -