Syntax Error with unicorn phat

OK so I am back again with my Unicorn pHAT issues and I am following the official Pimoroni tutorial and i follow it just as it is. So i have put this in so far

import unicornhat as uh
uh.set_layout(uh.PHAT)
for x in range(8):
 for y in range(4):
  uh.set_pixel(x, y, 0, 255, 255)
uh.show()

Now the problem I’m getting is as I put in uh.show() it gives me a syntax error like this

File "<stdin>", line 4
    uh.show()
     ^
SyntaxError: invalid syntax

I don’t get why this is wrong so can someone please help me as this is the same as what it says to do and I am still a beginner for coding I think. Thank You.

I can’t see a syntax error, and a direct copy & paste of your code runs for me. Bizarre!

What program are you using for editing your Python code?

What for putting it in? I use the terminal on the raspberry pi.

You mean you copied and pasted what I put in?

Oh, directly into a Python repl (by running python and then typing) or via en editor like nano or vim?

Using terminal as an editor. So no not direct. But I did try it direct as well. I am doing it by typing sudo python3

I’m stumped! I must be missing something. Or perhaps it’s keyboard weirdness. Or something.

Quite often a syntax error like that can be caused by the previous line.

Could you possible type in the commands up to the point you get an error, and send a photo of your screen?

I can later (not on my pi right now) but I tried on the python 3 app itself and it still gives a syntax error but says something else. I forgot what that was but I will send it soon. Unless you can manage to make yours stop working! Maybe it’s something to do with the software I am using. I’m using raspian Jessie. But I wouldn’t expect that to change anything since it’s still python. Strange.

I am having the same issue with a Mood Light kit I just picked up last week. I got the blinking example to work just fine from the walk through but I did not get this example to work. I plan to use it as a night light for one of my daughters and honestly I am extremely new to coding.

@onraf Please reply if you work it out.

I am going to try and get pictures of what is happening on lunch. I have tried using two separate keyboards.
@gadgetoid what all would you need to see in the pictures?

It’s tricky- some idea of what software you’re using and the steps leading up to the error would be helpful though.

If you can snap photos showing the error and the complete code at the time it happened I may be able to spot what’s awry, or possibly re-create it.

https://photos.app.goo.gl/FaPWft8Fo5zoCp0R2https://photos.app.goo.gl/APciRuRbfBMs60vT2

Google Photos

Here’s what I have right now.

Yes that is exactly what I got. Anyone out there know how to fix it???

I think that the issue is that the uh.show() is still within the for loop even though it looks like it’s not. When you’ve typed the uh.set_pixel(x, y, 0, 255, 255) line, you have to press enter twice to get it to close the for loop. Then, if you type the uh.show() line and press enter, it should work. :-)

Thank You so much. I haven’t actually tried it yet but I have a feeling it will work