#๐Ÿ”’ I made a cookie clicker and it don't work :/

32 messages ยท Page 1 of 1 (latest)

ornate elkBOT
#

@bright rain

Python help channel opened

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.

bright rain
#

this is my code

ripe plaza
bright rain
#

i can't post it

#

:/

still tide
#

!code

ornate elkBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

bright rain
#

'''py

#

ho

#

i don't know why but the code can't be posted :/

dapper orbit
#

!paste

ornate elkBOT
#
Pasting large amounts of code

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.

bright rain
cobalt citrus
#

What about it isn't working? Do you get an error?

bright rain
#

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)

cobalt citrus
#

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?

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

cobalt citrus
#

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

bright rain
#

hooo okay

#

i'll try

#

that's goo thanks man

cobalt citrus
#

cool, no problem ๐Ÿ‘

ornate elkBOT
#
Python help channel closed

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.