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
>
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.
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:
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
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
"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
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
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
> 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
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
10 matches
Mail list logo