Skip to content

typeerror 'nonetype' object is not iterable #1945

Answered by AlmazKad
AlmazKad asked this question in Q&A
Discussion options

You must be logged in to vote

oh, i feel so dumb right now.
well, the code was outputting "none" and going into an infinite loop where new data was not being read. i should have just used the "if" condition, not the "while" loop for checking is there new data. like in the code below.

while True:
    data = hub.ble.observe(1)
    print(data)
    if data is None:         #I'm talking about this line
        hub.light.on(Color.RED)
        wait(100)
    else:
        hub.light.on(Color.GREEN)

now the data is being sent and received. the led is green. as expected. all that's left is to handle stopping the motors.
thanks a lot!!

Replies: 2 comments 10 replies

Comment options

You must be logged in to vote
4 replies
@AlmazKad
Comment options

@laurensvalk
Comment options

@AlmazKad
Comment options

Answer selected by laurensvalk
@laurensvalk
Comment options

Comment options

You must be logged in to vote
6 replies
@AlmazKad
Comment options

@dlech
Comment options

@AlmazKad
Comment options

@dlech
Comment options

@AlmazKad
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants