Getting error message even when I copy and paste the code from the lesson

How come the output isn’t what was expected when it is the same as the left hand example?

Because the left side you are referring to is not the instruction you need to follow. Each screen usually has a Learn section and an Instructions section. You need to carry out the instructions in the latter and submit those.