Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
enumeration code help
#4
You can take advantage of list comprehension:

>>> lst = [1, 2, 3]
>>> [x * 2 for x in lst]
[2, 4, 6] 
It 'reads' something like that: give me element multiplied with 2 for for every element in lst
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
enumeration code help - by sar - Jan-22-2019, 04:56 PM
RE: enumeration code help - by ichabod801 - Jan-22-2019, 05:14 PM
RE: enumeration code help - by nilamo - Jan-22-2019, 05:14 PM
RE: enumeration code help - by perfringo - Jan-22-2019, 05:15 PM
RE: enumeration code help - by sar - Jan-22-2019, 05:50 PM
RE: enumeration code help - by DeaD_EyE - Jan-22-2019, 06:30 PM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020