#πŸ”’ Cannot access local variable

5 messages Β· Page 1 of 1 (latest)

flint sparrow
#

I am making a function to display the sokoban level as custom emojis, but in the lvl.replace("#", w), it says that it can't access local var, somebody pls help?

def display_lvl_as_emoji(lvl, emoji) -> str:
    match emoji:
        case 0x5865F2: w = ":wall_veasy:"
        case 0x57F287: w = ":wall_easy:"
        case 0xF1C40F: w = ":wall_med:"
        case 0xED4245: w = ":wall_med2:"
        case _: ":wall_med:"

    lvl = lvl.replace("#", w)
    lvl = lvl.replace("@", ":player:")
    lvl = lvl.replace("+", ":playerflush:")
    lvl = lvl.replace("$", ":box:")
    lvl = lvl.replace("*", ":box2:")
    lvl = lvl.replace(" ", ":floor:")
    lvl = lvl.replace(".", ":floor2:")
    return lvl

also because of discord formatting the emojis is not in brackets properly

signal lagoonBOT
#

@flint sparrow

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.

#

@flint sparrow

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.

#

πŸ”’ Cannot access local variable