Python Forum

Full Version: Get all values of for loop with an index
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I've read a text file and got my ten lines with a for loop:
j = 871
i=0
counter = list(range(10))
for i in counter:
    CYC1=('\n'.join(map(str, f06FileSpecM1[j+i:j+i+1])))
    print(CYC1) [color=#2ECC71]#if I let it print here I get all lines but if I go out of the for loop I get again only the last line[/color]
    i=i+1
Now I want to get a value with the index [62:71]. Its for all ten lines the same. But if I try it with:
cmm = (CYC1[62:71]
I only get the value of the last line.
How is it possible to get all the ten values?
Thanks for your help :D
Append the items to a list.
Yes! I made an append but now my new list has 10 elements. How can I split them to get every element fro 62 to72? Already tried with another for loop ://