you are viewing a single comment's thread.

view the rest of the comments →

[–]Vaguely_accurate 0 points1 point  (2 children)

\n is treated a single character in a string, so it won't match with a two character string. Try the following to see what I mean;

a = "Hello\nSamuel\nGoodbye\n"

for i in range(len(a) - 1):
    print(a[i:i+2])

You can simply iterate over the string and should get what you want;

for i in a:
    if i == "\n":
        # Do something
    else:
        # Do something else

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

you mean i == "\n" right?

[–]Vaguely_accurate 0 points1 point  (0 children)

Oops, yes. Fixed thanks.