Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 1585

Python • SyntaxError: invalid syntax ---> "

$
0
0
When I typed the example code:

Code:

for n in range(2, 10):    for x in range(2, n):        if n % x == 0:            print(f"{n} equals {x} * {n//x}")            break4 equals 2 * 26 equals 2 * 38 equals 2 * 49 equals 3 * 3
on https://docs.python.org/3/tutorial/controlflow.html in terminal, it always prompt:

Code:

  File "<stdin>", line 4    print(f"Found an even number {num}")                                                                       ^SyntaxError: invalid syntax
What's wrong?

Statistics: Posted by MianQi2019 — Tue Oct 21, 2025 3:37 am



Viewing all articles
Browse latest Browse all 1585

Trending Articles