problem with comparing string with ‘{‘ sign

The last index of a string or list is len() - 1. You should probably use a for ... in ... loop anyway. In fact, you can get rid of the loop entirely by checking if a substring is in a string using sub in my_string.

Leave a Comment