Reputation:
I have this Python code:
import re
s = "aa67bc54c9"
for t, n in re.findall(r"([a-z]+)([0-9]+)", s)
And I get this error message when I try to run it:
File "<stdin>", line 1
for t, n in re.findall(r"([a-z]+)([0-9]+)", s)
^
SyntaxError: invalid syntax
How can I solve this? I am new to Python.
Upvotes: 4
Views: 254
Reputation: 53310
for
starts a loop, so you need to end the line with a :
, and put the loop body, indented, on the following lines.
EDIT:
For further information I suggest you go to the main documentation.
Upvotes: 7
Reputation: 258128
You need a colon (:
) on the end of the line.
And after that line, you will need an indented statement(s) of what to actually do in the loop. If you don't want to do anything in the loop (perhaps until you get more code written) you can use the statement pass
to indicate basically a no-op.
In Python, you need a colon at the end of
Upvotes: 4