Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
enumeration code help
#2
Please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.

I'm not sure what you need enumerate for, you don't seem to be using idx. However, a list comprehension will handle the multiplication problem:

newList = []
for rec in tmp:
    newList.append([item * 2 for item in rec])
It's a quick way to write a loop that creates a list. In fact, your whole code could be one big list comprehension:

newList = [[item * 2 for item in rec] for rec in tmp]
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
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