Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python

Python divisions

My code: https://w.trhou.se/wccgsg2sf1

On line 132 to 134 the divisions doesn't seem to be working but I have no clue why

Asking for help :}

2 Answers

Steven Parker
Steven Parker
243,318 Points

I already answered this along with your Combat System question! :stuck_out_tongue:

But recapping: These lines cause an error if the attack value is an odd number.

You probably want this, to guarantee the arguments are integers:

    PAttack = random.randint(math.floor(PlayerIG.attack / 2), PlayerIG.attack)
    EAttack = random.randint(math.floor(enemy.attack / 2), enemy.attack)

You'll also need to import math.

I know I tried that but I still get the same error

It worked fine till i updated my game with a shopping system error :unsupported operand type(s) for /: 'NoneType' and 'int'

Steven Parker
Steven Parker
243,318 Points

Oh, I see. Since the last time, you removed the attack property from Player. So now when you reference "PlayerIG.attack" it returns "None" instead of the value that it used to.

:point_right: You need to either put the attack property back in Player, or update the attack function to use the new base_attack property.

Oh yeah I didn't notice that. Thanks a lot once again

I know I tried that but I still get the same error

It worked fine till i updated my game with a shopping system error :unsupported operand type(s) for /: 'NoneType' and 'int'