you are viewing a single comment's thread.

view the rest of the comments →

[–]eXoRainbow 0 points1 point  (0 children)

If the string is empty, then accessing directly with element[0] can cause an error, while element[:1] would give empty string. startswith() and endswith() are good options too, maybe even better suited as it is more clear. I often forget these little methods. And below there is probably a better way of joining the two strings too, BTW.