Why is this tokenizer not catching keywords?

Viewed 23

This is what the method looks like.

I'm trying to make a basic Python tokenizer that takes a str input and makes token out of it, catching symbols, numbers and keywords. It detects numbers and symbols fine, but not the "print" part.

['', {'number': '5'}, '', '+', '', {'number':'3'}]

This is the result i get.

Can someone please explain why this doesn't work and maybe how to make it work ? Thank you.

0 Answers
Related