Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
enumeration code help
#1
Hi there, I am a new user of python and just want to know if there is anyway to shorten by below code in a way that I can multiply all records with a single value. At the moment I am selecting every single rec and multiplying it individually.
newList = []
for idx,rec in enumerate(tmp):
    newList.append ((rec[0]*2, rec[1] *2, rec[3] *2,
    rec[4] *2))
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