#๐ Please help.
29 messages ยท Page 1 of 1 (latest)
@late quiver
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.
I genuinely dont know whats wrong and need help like really urgently.
variables defined inside functions only exist inside that function
I wouldn't be defining constants inside a function
the variable only exists inside the function
you're creating variables that only exist inside the calculate_bill function
So how do I fix that
you can define it outside the function
x = "hello world"
def func(y):
print(y)
func(x)```
you can pass variables to functions this way
So just put the def calculate_bill after the constant definitions
the order here isn't the issue
I don't actually know what you're trying to do
so it's difficult to tell you the best option
Just make a calculator for a project
And for some reason its telling me one of the variables is undefined
ok, so one option is to simply indent everything under that function
now you need to call the function
add calculate_bill() at the very bottom (not indented)
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.