Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Select a part of an element of a list with Index
#1
I've created a list with a for loop and got elements with many elements... How can I make this easier?

    cmc = []

    CYC1 = cmc[0]

    CYC2 = cmc[1]

    CYC3 = cmc[2]

    CYC4 = cmc[3]

    c = []

    c.append(CYC1[67:79])

    c.append(CYC2[67:79])

    c.append(CYC3[67:79])

    print(c)
you don't need the intermediate cyc variables:
for i in range(4):
    c.append(cmc[i][67:79])
Larz60+ wrote Aug-09-2019, 11:15 AM:
Please post all code, output and errors (in it's entirety) between their respective tags. I did it for you this time, Here are instructions on how to do it yourself next time.
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  list.index() help qmfoam 4 179 Aug-07-2020, 07:25 PM
Last Post: qmfoam
  Select correct item from list for subprocess command pythonnewbie138 6 290 Jul-24-2020, 09:09 PM
Last Post: pythonnewbie138
  Function to return list of all the INDEX values of a defined ndarray? pjfarley3 2 166 Jul-10-2020, 04:51 AM
Last Post: pjfarley3
  Finding an element in a 1d list in a 2d array lionrocker221 0 242 Jun-27-2020, 04:50 PM
Last Post: lionrocker221
  removing dictionary element in list using (key, value) MelonMusk 3 261 Jun-13-2020, 02:37 PM
Last Post: buran
  using element on a list as condition statement glennford49 11 568 May-21-2020, 12:53 PM
Last Post: hussainmujtaba
  Find index value in List Martin2998 3 330 May-12-2020, 02:17 PM
Last Post: deanhystad
  Compare Two Lists and Replace Items In a List by Index nagymusic 2 394 May-10-2020, 05:28 AM
Last Post: deanhystad
  count each element in a list glennford49 9 509 May-01-2020, 11:20 AM
Last Post: glennford49
  Alpha numeric element list search rhubarbpieguy 1 231 Apr-01-2020, 12:41 PM
Last Post: pyzyx3qwerty

Forum Jump:


Users browsing this thread: 1 Guest(s)