[Tutor] Beginner - Clarifying 'understanding randint arguments'
Alan Gauld
alan.gauld at btinternet.com
Mon Feb 17 16:33:27 CET 2014
On 17/02/14 11:39, Marc Eymard wrote:
> Hi Tutor,
>
> The previous elements I sent to the mailing list were incomplete and
> needs no answer from Tutor.
But you got several nonetheless.
Did you read them?
If so you will know that calling randint() does not change the two
xxx_range variables. It simply returns a random number as requested.
You will need to modify the range values yourself.
> Hope this clarifies my previous email (see further down this note).
> >>> import random
> >>> low_range = -1
> >>> high_range = 101
> >>> random.randint(low_range + 1, high_range - 1)
> 56
> >>> low_range
> -1
> >>> high_range
> 101*
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
http://www.flickr.com/photos/alangauldphotos
More information about the Tutor
mailing list