View Single Post
Old 08-22-2016, 11:50 AM   #155
SirBlurton
High School Varsity
 
Join Date: Feb 2007
You could also use a list comprehension to skip the step of appending to the created list and just create the list.

Code:
A=[(4+random.random()) for i in range(8)]

List comprehensions were one of the best things I've learned about. I had one block of about 12 overly complicated lines in an early project get replaced by one list comprehension....and that simplification flowed through everything else.
SirBlurton is offline   Reply With Quote