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 trialsaro lin
Courses Plus Student 531 Pointsdoubt!
I know it not the apt stage to ask this simple doubt. But please clarify it.
roll=random.randint( 1 , self.attack_limit)
In the above statement why ' 1 ' is used as one of the parameter?
1 Answer
Anish Walawalkar
8,534 PointsIn [8]: random.randint?
Signature: random.randint(a, b)
Docstring: Return random integer in range [a, b], including both end points.
File: /usr/local/Cellar/python3/3.4.3_2/Frameworks/Python.framework/Versions/3.4/lib/python3.4/random.py
Type: method
Using the randint(a,b) function of the random module returns a random in the specified range. Now I'm assuming that in your example:
roll=random.randint( 1 , self.attack_limit)
roll represents an attack variable. Therefore you're variable cannot have a value of '0', hence you specify '1' for the start of the range