Re: Random number help

2016-11-23 Thread Larry Hudson via Python-list
On 11/23/2016 11:17 AM, Thomas Grops wrote: I need a way of generating a random number but there is a catch: I don't want to include certain numbers, is this possible? random.randint(1,100) works as it will randomly pick numbers between 1 and 100 but say i don't want 48 to come out is there a

Re: Random number help

2016-11-23 Thread Thomas Grops via Python-list
Thankyou for all your help I have managed to pick a way that works from your suggestions :D -- https://mail.python.org/mailman/listinfo/python-list

Re: Random number help

2016-11-23 Thread MRAB
On 2016-11-23 19:29, Chris Kaynor wrote: On Wed, Nov 23, 2016 at 11:17 AM, Thomas Grops via Python-list wrote: I need a way of generating a random number but there is a catch: I don't want to include certain numbers, is this possible? random.randint(1,100) works as it will randomly pick numbe

Re: Random number help

2016-11-23 Thread Thomas Grops via Python-list
On Wednesday, 23 November 2016 19:30:21 UTC, Chris Kaynor wrote: > On Wed, Nov 23, 2016 at 11:17 AM, Thomas Grops via Python-list > wrote: > > I need a way of generating a random number but there is a catch: > > > > I don't want to include certain numbers, is this possible? > > > > random.randint

Re: Random number help

2016-11-23 Thread Thomas Grops via Python-list
On Wednesday, 23 November 2016 19:30:04 UTC, Thomas Nyberg wrote: > On 11/23/2016 02:17 PM, Thomas Grops via Python-list wrote: > > I need a way of generating a random number but there is a catch: > > > > I don't want to include certain numbers, is this possible? > > > > random.randint(1,100) work

Re: Random number help

2016-11-23 Thread Achilleas Michailidis
You can use a while statement until you get a number out of your excluded numbers excludedNumbers = [1,2,3,4] randomNumber = random.randomint(1,100) while randomNumber in excludedNumbers: randomNumber = random.randomint(1,100) After the while you have a number outside the excluded nu

Re: Random number help

2016-11-23 Thread Chris Kaynor
On Wed, Nov 23, 2016 at 11:17 AM, Thomas Grops via Python-list wrote: > I need a way of generating a random number but there is a catch: > > I don't want to include certain numbers, is this possible? > > random.randint(1,100) works as it will randomly pick numbers between 1 and > 100 but say i do

Re: Random number help

2016-11-23 Thread Thomas Nyberg
On 11/23/2016 02:17 PM, Thomas Grops via Python-list wrote: I need a way of generating a random number but there is a catch: I don't want to include certain numbers, is this possible? random.randint(1,100) works as it will randomly pick numbers between 1 and 100 but say i don't want 48 to come

Re: Random number help

2016-11-23 Thread Marko Rauhamaa
Thomas Grops : > random.randint(1,100) works as it will randomly pick numbers between 1 > and 100 but say i don't want 48 to come out is there a way of doing > this. It needs to be an integer too so not a list unless there is a way > to convert list to int r = 48 while r == 48: r = r

Random number help

2016-11-23 Thread Thomas Grops via Python-list
I need a way of generating a random number but there is a catch: I don't want to include certain numbers, is this possible? random.randint(1,100) works as it will randomly pick numbers between 1 and 100 but say i don't want 48 to come out is there a way of doing this. It needs to be an integer