Ask coding questions

← Back to all posts
How to fix "[pyflakes] invalid syntax" in a while loop?
RixTheTyrunt

In the bottom, you will find my Python code of a file named main.py, but let's talk about the error that will appear, when you will run!

Answered by Coder100 [earned 5 cycles]
View Answer
Comments
hotnewtop
Coder100

Silly, that's not python!

python doesn't have braces!

RixTheTyrunt
RixTheTyrunt

@Coder100 Now, it's returning three same texts that are like this: "Hello, Replit!"! Thank you, my first helper on Repl.it!

RixTheTyrunt

@Coder100 Then, how to END the loop?

ch1ck3n

@SnackyPlusPlus

put break whereever you want to end the loop

RixTheTyrunt

@Coder100 NOW HOW TO ERASE ALL THOSE MANY NUMBERS?!

RixTheTyrunt

@ch1ck3n Aww, now it's showing File main.py, line 5 if count = 10 ^ SyntaxError: invalid syntax...

CosmicBear

@SnackyPlusPlus you need another equals sign.`py
if count == 10:
break

ch1ck3n

@SnackyPlusPlus
if count == 10: is what you actually need

Coder100

one thing, you don't need the if statement to end the loop at all! The loop ends when the condition is false, and all you are doing is breaking when python already knows when to break. @SnackyPlusPlus