#๐ I made a cookie clicker and it don't work :/
32 messages ยท Page 1 of 1 (latest)
@bright rain
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
this is my code
||theres no code anywhere||
!code
!paste
If your code is too long to fit in a codeblock in Discord, you can paste your code here:
https://paste.pythondiscord.com/
After pasting your code, save it by clicking the Paste! button in the bottom left, or by pressing CTRL + S. After doing that, you will be navigated to the new paste's page. Copy the URL and post it here so others can see it.
What about it isn't working? Do you get an error?
yes
i'll show you
line 355, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
ah ok, I see. Calling read on a file twice will not work as you expect in your readJson function. The second time it will return nothing because you've already read through the whole file, so there's nothing new to read.
Try storing what you read in a variable first, then you can use it multiple times, e.g.
data = file.read()
if len(data) == 0 and False:
file = open(fichier, "w+")
file.write('{' + f' \n"nombre_cookie" : 0, \n"bonus" : 1,'
f' \n"prix_amelioration" : 20,'
f' \n"production_par_seconde" : 0,'
f' \n"prix_amelioration_bat" : 50 \n' + '}')
return json.loads(data)
does that make sense @bright rain?
ty so much
but it don't work too :/
NameError: name 'file' is not defined. Did you mean: 'filter'?
that's the error
@cobalt citrus if you don't know how to fix that it's okay
Do you still have the top line of your function, file = open(fichier, "r+")? I didn't mean to suggest you should remove that, you still need it
cool, no problem ๐
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.