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
Nicholas Anstis
2,095 PointsPython 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
243,318 PointsI already answered this along with your Combat System question!
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.
Nicholas Anstis
2,095 PointsI 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'
Nicholas Anstis
2,095 PointsNicholas Anstis
2,095 PointsI 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
243,318 PointsSteven Parker
243,318 PointsOh, 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.
Nicholas Anstis
2,095 PointsNicholas Anstis
2,095 PointsOh yeah I didn't notice that. Thanks a lot once again