How do I get index of line

ipsissimus

I'm reading the file, so how do I get the turns, or index for each line?

for line in excelRead:
    keywrds=[]
    title=line.split("+")
    title=[lines.strip()for lines in title]
    print title[0]

So, when I read my first line in excel, line variable is equal to line value in excel, but how do I find which turn it is?

shaktimaan

Use enumerate():

for index, line in enumerate(excelRead, start=1):
    keywrds=[]
    title=line.split("+")
    title=[lines.strip()for lines in title]
    print title[0]
    print index

The start parameter to the enumerate indicates that you want to start the index at 1, instead of 0.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How do I get index of line

From Dev

How do I get the line and column number of a character at some index in Text View?

From Dev

How do I get the ListTile index in an ExpansionTile?

From Dev

How do i get Object index in an array

From Dev

How do I get the index of an object in this array?

From Dev

How do I get Index of Listview?

From Java

How do I get a curve point on a line?

From Dev

How do I get rid of this new line?

From Dev

How do I get output on same line

From Dev

How do I get rid of this new line?

From Dev

How do I get the length of the first line in a multi line string?

From Dev

How do i get my repeater results to appear line by line

From Dev

How do I get index of element in std::deque

From Dev

How do I get the list of all terms in a Whoosh index?

From Dev

How do I use indexOf to get the index of a selected NSCollectionView?

From Java

How do I get the key at a specific index from a Dictionary in Swift?

From Dev

How do I get the index of a Widget in onPreviewDrop() in a VerticalPanel?

From Dev

How do I get the index of a type matching some predicate?

From Dev

How do I get the index of each item in a groupby object in Pandas?

From Dev

How do I get the name of the rows from the index of a data frame?

From Dev

How do I get statistics about my recoll index?

From Dev

How do I get a list item by index in elm?

From Dev

How do I get the index for an element in a NSMutableArray in Swift?

From Dev

How do I get the index of multiple occurrences of the same character in a string?

From Dev

How do I get the index of the current element in a for loop in Rust?

From Dev

How do I get the index of the current element in a for loop in Rust?

From Dev

How do I get statistics about my recoll index?

From Dev

Rails 4: how do I get ID on the index page?

From Dev

How do I get the index of a Widget in onPreviewDrop() in a VerticalPanel?

Related Related

  1. 1

    How do I get index of line

  2. 2

    How do I get the line and column number of a character at some index in Text View?

  3. 3

    How do I get the ListTile index in an ExpansionTile?

  4. 4

    How do i get Object index in an array

  5. 5

    How do I get the index of an object in this array?

  6. 6

    How do I get Index of Listview?

  7. 7

    How do I get a curve point on a line?

  8. 8

    How do I get rid of this new line?

  9. 9

    How do I get output on same line

  10. 10

    How do I get rid of this new line?

  11. 11

    How do I get the length of the first line in a multi line string?

  12. 12

    How do i get my repeater results to appear line by line

  13. 13

    How do I get index of element in std::deque

  14. 14

    How do I get the list of all terms in a Whoosh index?

  15. 15

    How do I use indexOf to get the index of a selected NSCollectionView?

  16. 16

    How do I get the key at a specific index from a Dictionary in Swift?

  17. 17

    How do I get the index of a Widget in onPreviewDrop() in a VerticalPanel?

  18. 18

    How do I get the index of a type matching some predicate?

  19. 19

    How do I get the index of each item in a groupby object in Pandas?

  20. 20

    How do I get the name of the rows from the index of a data frame?

  21. 21

    How do I get statistics about my recoll index?

  22. 22

    How do I get a list item by index in elm?

  23. 23

    How do I get the index for an element in a NSMutableArray in Swift?

  24. 24

    How do I get the index of multiple occurrences of the same character in a string?

  25. 25

    How do I get the index of the current element in a for loop in Rust?

  26. 26

    How do I get the index of the current element in a for loop in Rust?

  27. 27

    How do I get statistics about my recoll index?

  28. 28

    Rails 4: how do I get ID on the index page?

  29. 29

    How do I get the index of a Widget in onPreviewDrop() in a VerticalPanel?

HotTag

Archive