Skip to content

Commit 0034ce2

Browse files
committed
For-loop through characters in file, instead of while-looping with the index
1 parent 260c61c commit 0034ce2

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Python/ini_converting/ini_parser.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,15 @@ def get_depth(token):
7575
def get_token_pos(token):
7676
with open(token["filepath"], "r") as f:
7777
text = f.read()
78-
i = 0
78+
7979
line = 1
8080
column = 1
81-
while i < token["index"]:
82-
if text[i] == '\n':
81+
82+
for char in text[:token["index"]]:
83+
if char == '\n':
8384
line += 1
8485
column = 0
8586
else:
8687
column += 1
87-
i += 1
88+
8889
return line, column

0 commit comments

Comments
 (0)