Math.floor and Math.random

Guys whats the best way of writing this code?

Use the addition operator (+) to add a random number between 1 and the value of xp to your monsterHealth variable change.

Hello! @kevinmu

import random

xp = # some val
monster_health = # some val

random_damage = random.randint(1, xp)
monster_health += random_damage

are u implying something like this…?

1 Like

If you have a question about a specific challenge as it relates to your written code for that challenge and need some help, click the Ask for Help button located on the challenge (it looks like a question mark). This button only appears if you have tried to submit an answer at least three times.

The Ask for Help button will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

Yes, that’s the one. Many Thanks.

1 Like

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.