Syntax error where there is none.
https://repl.it/@DUN0040/A-Basic-Bitlife
It says on line 38 at the last bracket that it is an invalid syntax where it isn't unless I am forgetting something because in my game it's supposed to be like bit life where it kills you at a random age so if someone could help I would be indebted.
ash15khng
You're actually missing the colon there.
The problem in line 38 is that you haven't put a colon after the condition in your while loop. And after the colon, you should also indent all the code you want to be inside the loop.
However, there are actually quite a few other things wrong with the code.
First off, you don't write
int(5)
, you just write5
. Sayingint(5)
means you're passing5
(which is already anint
) toint
which gives you back the same 5 you put in. As you can see, that doesn't make much sense.At line 195, you say
from goto import *
, which is unnecessary because you already did that at the beginning of the script.At lines 194, 215, and 391, the
if
statements aren't indented right.The range function takes either 1, 2, or 3 arguments.
range(1, 10, 2)
gives you[1, 3, 5, 7, 9]
So you can't say
range(0, 1, 2, 3)
like you do at line 35. You might be looking for[0, 1, 2, 3]
, which is the same asrange(4)
.Similarly, you also can't say
random.randint(0,1,2,3)
at line 36, becauserandint
takes in 2 arguments, the first being the minimum value of the random number and the second being the maximum value of the random number. If you're trying to get a number between 0 and 3, you should dorandom.randint(0, 3)
These are just the ones I spotted right away, There are actually quite a bit more.
If you did make this game, I'd recommend testing out things more often. Otherwise, you'll end up with bugs like these that are much harder to fix later on.