+ 2
What's wrong with the syntax?
File "loading.py", line 13 print(hl + " Progress:[" + str(perc) + "%]"+ normal + "[" + progress + empty + "]", end="\r") ^ SyntaxError: invalid syntax What is it with the syntax that is wrong? The variables is defined earlier in the whole script so never mind the variables.
6 Respostas
+ 2
Gotcha. Found your problem for you.
CHANGE:
perc = int(float(per) * 100
TO:
perc = int(float(per)) * 100
Sometimes Python will generate the error on the line where it gets stuck, but the problem is sometimes just coming from the line prior. In this case, you just forgot your closing parenthesis.
+ 1
Hard to say since you didn't provide your code. Maybe put "" + hl at the beginning so it realizes that it's a string instead of a calculation. I'm no Python expert, so test it and let me know.
If you can post link to your code, I can tell you with 100% certainty.
+ 1
import time
normal = "\033[0m"
hl = "\33[102m"
for x in range(11):
progress = "=" * x
em = 11 - len(progress) - 1
empty = " " * em
per = "0." + str(x)
perc = int(float(per) * 100
print(hl + " Progress:[" + str(perc) + "%]"+ normal + "[" + progress + empty + "]", end="\r")
time.sleep(1)
print(" ")
+ 1
It doesn't work in sololearn so you'll have to use the IDE.
+ 1
the line before print misses a ) at the end. Could that be the problem?
https://code.sololearn.com/cS2n91O4sPS5/?ref=app
+ 1
Thanks!