Home/Support/Support Forum/Why is this a syntax error?
Welcome to Digi Forum, where you can ask questions and receive answers from other members of the community.

Why is this a syntax error?

0 votes
Hi,

I'm a total noob with MicroPython. I'm trying to do something I expect would be easy, but I get a syntax error for <stdin>.
Here's the snippet that fails. It's actually the second line that generates the error.

if(stdin.buffer.any() > 34)

data = stdin.buffer.readline()

The error is;
Traceback (most recent call last):
File "<stdin>", line 108
SyntaxError: invalid syntax

Thanks in advance if you don't mind helping me out.
Glenn
asked Jan 19 in Python by Glenn Hamblin New to the Community (6 points)

Please log in or register to answer this question.

1 Answer

0 votes
The forum mangled your code but I'll make a best-effort guess.

Your `if` statement doesn't look right; it does not end with a colon. Syntactically it should be `if (stdin.buffer.any() > 34):`

Try that, but I also suspect your `if` statement itself won't work...never seen `any` used like that.
answered Feb 15 by starfish New to the Community (5 points)
...