#๐Ÿ”’ I don't understand how I am getting this error and I know how to fix it

15 messages ยท Page 1 of 1 (latest)

timid sundialBOT
#

@loud light

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.

lime spoke
#

well assuming that you do not have anything past the if-else that uses contact_obj, then the warning (not error) would be correct

#

what is your expected result?

lethal sedge
#

... and to be clear, these are just linter warnings. If your code is still incomplete because you haven't done anything with context_obj yet, but are going to, these warnings can be ignored until later when things are complete.

loud light
#

Do I need contact_obj to be globalized and set the value to None?

loud light
lethal sedge
loud light
#

Ahh i see

#

I fixed it

lethal sedge
#

Oh. Only one of those will run at any given time. So that doesn't count.
So this:

if whatever:
    x = 1
else:
    x = 2

does not use the value of x. But this:

if whatever:
    x = 1
else:
    x = 2
print(x)

does use it.

loud light
#

contact_obj was only referenced in the else block

#

Thanks for the help

timid sundialBOT
#
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.