Python Forum

Full Version: Select a part of an element of a list with Index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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])