@median basin
#Why is this invalid syntax?
56 messages · Page 1 of 1 (latest)
start = input("|||START:k|||")
while start == ("k"):
answer = input("|||Press Enter x2||")
if (answer== input()):
guntopt = (random.choice(guntype))
print ("-------------------------")
print ("|GUN TYPE: " + guntopt)
print ("|GUN SIZE:",(random.choice(gunsize)))
if guntopt == ("redpowder"):
print ("|SHOTS: " + (random.choice(rpshots))
print ("|COOLDOWN:" + (random.randint(1,2) + "seconds")
if guntopt == ("hybrid"):
print ("|SHOTS: " + (random.choice(bsshots))
print ("|COOLDOWN:" + (random.randint(1,4) + "seconds")
if guntopt == ("bloodshot"):
print ("|SHOTS: " + (random.choice(bsshots))
print ("|COOLDOWN:" + (random.randint(1,2) + "seconds")
if guntopt == ("rayspitter"):
print ("|SHOTS: Ammoless)
print ("|COOLDOWN:" + (random.randint(1,6) + "seconds")```
specifically this part
One ( too much
Have a look at the previous line above where the error is pointing to. Count the number of parenthesis you have
Also you don't need the parentheses in the comparisons
ahhhhh ty omg
same error, fixed all the parenthasies
Do the same thing
what do you mean by comparisons?
The amount of brackets makes me think this is Lisp
if guntopt == ("redpowder"): could be if guntopt == "redpowder":?
aahh
?
Half the brackets on the screenshot are redundant
It's a programming language in which brackets are used a lot. Some of the brackets in your code are unnecessary
Missing another one in line 46
@median basin You should be pasting your code to share it. That way people can copy it and modify it to show you how many brackets can be reduced.
i did up here
it's giving me a different error now
The issue in line 46 is still there
Like I said
Just count your parentheses, should be the same amount of opening and closing ones
Also things might be clearer if you get rid of the ones you don't actually need
print ("|COOLDOWN:" + (random.randint(1,4)) + "seconds")
it says this is invalid syntax
Yeah
Because the line before that is incorrect
Did you read the 3 messages in which I told you line 46 is the issue?
You can't concatenate ints and str?
3 opening, 2 closing
Did you not test your code while writing it? There are so many errors
Like I test my code after some progress. I run into fewer errors if I do that instead of writing the whole thing at once
I do test it, it's just that there is a section underneath this one that has the exact same structure so I copy pasted it and changed the variables & strings it spits out
Concatenation is putting one thing next to another. The error is telling you that you can't put a string and an integer together. This is because they're two different data types and python doesn't know exactly how you want to handle the + between them
Ahh ok
not rob has provided some ways to get it working
I'll just take out the "seconds" part
Either using string formatting (f-strings) or convert the integer into a string (which will allow string to string concatenation)
or you can use vim motion
also I apologize for the repeated errors with the parenthasies, I have dyslexia and I have serious issues determining how many of one sort of symbol there are next to each other.
probably better to code in an IDE and install an extension for colorful brackets then
I'm on a chromebook, online-python is the best browser based one I know of.
I will now exit this thread so that it stays safe for work and wish all of you the best of luck with magic Python things 🗿
Lmao fair enough
we told you twice how to do it...
str(random.randint(1,2)) like this?
yes