Yvan Alpay
Yvan Alpay

Reputation: 13

Can't pinpoint the exact nonetype error in Python

I've been doing a rather basic project in my fundamentals of software development class (I'll apologize in advance for my code), it's basically making a snakes and ladders which generates random snakes and ladders.

The error starts at around line 66, with the specific error being: if FirstPlayerPosition > 99: TypeError: '>' not supported between instances of 'NoneType' and 'int'

Here's my github link to it, anyone can lend a hand?

Upvotes: 1

Views: 62

Answers (1)

David Liaw
David Liaw

Reputation: 3393

def CheckForSnake(t):
    if t in SnakePositions:
        t -= 10
        print("Oops! You've been bitten, go down 10 cells. Your new position is: %s" %(t))
        return t
    else:
        return t

CheckForSnake function had a chance to not return if t isn't in SnakePositions same goes for the CheckForLadder function. You'll need to return something for when the if statement won't get called.

Upvotes: 1

Related Questions