Error running NER merge_tokens code in Colab

I am trying to follow along the course and running the NLP exercise #2 - Named Entity Recognition.

The merge_tokens function is as follows:

def merge_tokens(tokens):
merged_tokens =
for token in tokens:
if merged_tokens and token[‘entity’].startswith(‘I-’) and merged_tokens[-1][‘entity’].endswith(token[‘entity’][2:]):
last_token = merged_tokens[-1]
last_token[‘word’] += token[‘word’].replace(‘##’,‘’)
last_token[‘end’] = token[‘end’]
last_token[‘score’] = (last_token[‘score’]+token[‘score’])/2
return merged_tokens

the error message I am getting is: in merge_tokens(tokens)
2 merged_tokens =
3 for token in tokens:
----> 4 if merged_tokens and token[‘entity_group’].startswith(‘I-’) and merged_tokens[-1][‘entity_group’].endswith(token[‘entity_group’][2:]):
5 last_token = merged_tokens[-1]
6 last_token[‘word’] += token[‘word’].replace(‘##’,‘’)

TypeError: string indices must be integers

Can anyone point out what i could be doing wrong? Been staring at it for quite a bit.
Thanks in advance!