Since the strings start with index 0, it is incorrect to iterate through the string using while i <= len(summary):
, you should use while i < len(summary):
instead.
Better yet is to use something like:
for i in range(len(summary)):
solved problem with comparing string with ‘{‘ sign [duplicate]