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 trialNursultan Bolatbayev
16,774 PointsRandom choice
Hello. When I create new instances of Monster class or subclass of Monster with max and min attributes, why it always gives the max value (for hit_points and experience)? But it should be a random between max and min which is defined in def init()?
1 Answer
Matthew Hill
7,799 PointsWithout seeing your code it's difficult to give a proper answer, however, in your title for this question you said 'choice'. You should be getting a random integer from within the two specified parameters:
<p>
import random
minimum = 1
maximum = 5
example = random.randint(minimum, maximum)
</p>
Iain Simmons
Treehouse Moderator 32,305 PointsIain Simmons
Treehouse Moderator 32,305 PointsCan you please share your code by pasting it here inside code blocks (refer to the Markdown Cheatsheet linked below the question/answer/comment box), or by creating a Snapshot of your Workspace if you're using Workspaces?