#๐Ÿ”’ Unable to resolve 'NoneType' object has no attribute 'value'

14 messages ยท Page 1 of 1 (latest)

shadow cairnBOT
#

@near atlas

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.

outer hatch
#

@near atlas If you're trying to share code, you can't upload files. You'll have to paste it here

#

!code

shadow cairnBOT
#
Formatting code on Discord

Here's how to format Python code on Discord:

```py
print('Hello world!')
```

These are backticks, not quotes. Check this out if you can't find the backtick key.

For long code samples, you can use our pastebin.

near atlas
outer hatch
#

yup, thanks!

near atlas
#

For anyone looking at it, I'm sorry that the code is so terrible, I'm relatively new to programming and these assignments are murdering me

willow sequoia
#

looks like there are many instances where youre trying to access the .value but in this particular instance where youre seeing the error, the value is None so there is no value to access

#

ie you cant access instance variables of NoneType

proud tartan
near atlas
#

It seems I managed to resolve the error! But I think I messed up the logic of my code somewhere making the changes as the output is now different from expected.
As an update, I believe the error was caused by the code trying to access a particular root.left.value but root.left itself was a NoneType object as it has reached the lowest level of the tree hence the error was thrown.
In either case, big thanks to everyone who helped to look at it! Really appreciate it โค๏ธ

proud tartan
near atlas
#

!close

shadow cairnBOT
#
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.