#๐ Looking for help on this piece of code
17 messages ยท Page 1 of 1 (latest)
@chrome timber
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.
where do you define BiscuitTime?
thats the thing idk where i should
im sorry if i sound stupid i started python recently
def foo():
my_variable = 42
print(my_variable)
in that code above my_variable is only available in the foo function. Outside of it, it is not available. That's the basics of scope. Another way to think of it is that every level of indentation is a new level of scope, and you can't use a variable in the outer scope
while there are better ways to do it, since you're learning you can do something like this: ```py
my_variable = 42
def foo():
my_variable = "something else"
if ...:
my_variable = "a third thing"
alright ty
sure thing
if you want to do further reading on it, the keywords for that are global variable and global scope
alr
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.