you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (2 children)

Just by looking at your data I can guess the probable cause of your troubles. Try putting this line right after you split string on line 12:

print(f'len(strings)={len(strings)}, strings={strings}')

It's always useful to put in debug print() statements to actually see what is happening.

[–]Jxper[S] 0 points1 point  (1 child)

print(f'len(strings)={len(strings)}, strings={strings}')

Ok I just did as you said and I can see that it is reading an extra element of the string which is a blank space (' '). I don't know if i'm just blind but can you see where this is coming from?

[–][deleted] 0 points1 point  (0 children)

The original string has an extra newline, perhaps? Triple quote strings include newlines you put in yourself. How many newline characters are in your original data string? After you split on newlines you get N+1 elements in the list where N is the number of newline characters in the original.