Re: [Tutor] Need help understanding output...

2010-08-18 Thread Steven D'Aprano
On Wed, 18 Aug 2010 09:21:51 pm Laurens Vets wrote: > On 8/12/2010 1:26 AM, Steven D'Aprano wrote: > > On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: > >> I need to generate a list of 30 numbers randomly chosen from 1, 2, > >> 3, 4, 5& 6. However, I cannot have more than 2 numbers which are >

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Dave Angel
Laurens Vets wrote: Yes of course :) That's a typo on my part. I came up with the following which I think works as well? import random reeks = [] for i in range(60): temp = [random.randint(1, 6)] while reeks[-2:-1] == reeks[-1:] == temp: temp = [random.randint(1, 6)] if reeks.

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Laurens Vets
Thank you all for your help! I've added another condition to this program, namely, in a range of 60, each 'random' number can only occur 10 times. I came up with the following: import random series = [] for i in range(60): temp = [random.randint(1, 6)] while series[-2:-1] == series[-1:

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Evert Rol
On 18 Aug 2010, at 13:21 , Laurens Vets wrote: > On 8/12/2010 1:26 AM, Steven D'Aprano wrote: >> On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: >> >>> I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, >>> 4, 5& 6. However, I cannot have more than 2 numbers which are the

Re: [Tutor] Need help understanding output...

2010-08-18 Thread Laurens Vets
On 8/12/2010 1:26 AM, Steven D'Aprano wrote: On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5& 6. However, I cannot have more than 2 numbers which are the same next to each other. I came up with the following (Please

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Alan Gauld
"Laurens Vets" wrote next to each other. I came up with the following (Please ignore the fact that I'm trying to avoid an IndexError in a stupid way :)): Others have answered your question. I'll suggest that instead of using indexes its easier to just cache the last two values in variable

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Steven D'Aprano
On Thu, 12 Aug 2010 07:04:15 am Laurens Vets wrote: > I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, > 4, 5 & 6. However, I cannot have more than 2 numbers which are the > same next to each other. I came up with the following (Please ignore > the fact that I'm trying to avo

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Emile van Sebille
On 8/11/2010 2:04 PM Laurens Vets said... Hello list, I'm learning Python and I'm currently facing an issue with a small script I'm writing. I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & 6. However, I cannot have more than 2 numbers which are the same next to each

Re: [Tutor] Need help understanding output...

2010-08-11 Thread Evert Rol
> I'm learning Python and I'm currently facing an issue with a small script I'm > writing. > > I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & > 6. However, I cannot have more than 2 numbers which are the same next to each > other. I came up with the following (Plea

[Tutor] Need help understanding output...

2010-08-11 Thread Laurens Vets
Hello list, I'm learning Python and I'm currently facing an issue with a small script I'm writing. I need to generate a list of 30 numbers randomly chosen from 1, 2, 3, 4, 5 & 6. However, I cannot have more than 2 numbers which are the same next to each other. I came up with the following (P