Friday, 6 September 2013

Python For-loop and List Additions [on hold]

Python For-loop and List Additions [on hold]

I am having trouble understanding the following Python code:
name = ["John", "Eric", "Jessica"]
instances = []
tmpInstances = []
subMods = [n for n in names if 1]
for s in subMods:
tmpInstances += [instance(n) for n in name if 1]
instances += tmpInstances
This is how I see it, not sure if it is correct:
subMods = ["John", "Eric", "Jessica"]
tmpInstances = ["John", "Eric", "Jessica"]
instances = ["John", "Eric", "Jessica", "John", "Eric", "Jessica"]
Am I correct?

No comments:

Post a Comment