#๐ variable defined in "if" not available in "else"
22 messages ยท Page 1 of 1 (latest)
@languid delta
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.
x = 5
if True:
x = 42
else:
x = 0
you can define it first and then use it in the condition
it will be updated, if you reassign the correct value to it when you want to update
my problem is with the variable last_score
so i define it outside the if statement, update it in the if statement, and then i can reference it in the else statement? not sure if that makes sense but thats what i need in my code
yes
ahhhh okay thanks a lot
and it doesnt matter if i define it within or outside of the while loop, right? as long as its outside the if statement
nvm stupid question hahahah
variables defined in an if statement, stay in the IF statement block
as far as I know
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.