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
Post a Comment