On 04/02/15 13:06, Raúl Cumplido wrote:
There is a repeat argument on the product function that is used
exactly for what you want to do:
>>> for s in product(var, repeat=2)
print ''.join(s)
Good catch, I should have remembered that.
--
Alan G
Author of the Learn to Program web site
There is a repeat argument on the product function that is used exactly for
what you want to do:
>>> for s in product(var, repeat=2)
print ''.join(s)
On Wed, Feb 4, 2015 at 1:01 PM, Raúl Cumplido
wrote:
> sorry, just me being stupid :P should have read closely what the problem
> was
sorry, just me being stupid :P should have read closely what the problem was
On Wed, Feb 4, 2015 at 12:54 PM, Raúl Cumplido
wrote:
> I think you want to use combinations_with_replacement:
>
> >>> var = ['a', 'b', 'c', 'd', 'e']
>
> >>> length=int(raw_input("enter the length of random letters you
I think you want to use combinations_with_replacement:
>>> var = ['a', 'b', 'c', 'd', 'e']
>>> length=int(raw_input("enter the length of random letters you need "))
enter the length of random letters you need 2
>>> length
2
>>> from itertools import combinations_with_replacement
>>> [''.join(s
On 04/02/15 09:46, Suresh Kumar wrote:
print var
['a', 'b', 'c', 'd', 'e']
the user gave two so code should be like this
for i in itertools.product(var,var):
print i[0]+i[1]
output of code should be like this
aa
ab
...
ee
based on the user given input of length i need t
here is the sample code
>>> import itertools
>>> import string
>>> var=[]
>>> for i in string.ascii_lowercase[0:5]:
var.append(i)
>>>print var
['a', 'b', 'c', 'd', 'e']
>>> length=int(raw_input("enter the length of random letters you need "))
enter the length of random letters you need
On 03/02/15 22:51, Suresh Nagulavancha wrote:
This is my sample piece of code (not full code of my original code just sample
of it)
I am using python 2.7
Import itertools
var=[1,2,3,4,5]
Length=int(raw_input("length of possible numbers required"))
#This is for length of 3 chars
for i in itertool
On 03/02/2015 22:51, Suresh Nagulavancha wrote:
This is my sample piece of code (not full code of my original code just sample
of it)
I am using python 2.7
Import itertools
var=[1,2,3,4,5]
Length=int(raw_input("length of possible numbers required"))
#This is for length of 3 chars
for i in iterto
This is my sample piece of code (not full code of my original code just sample
of it)
I am using python 2.7
Import itertools
var=[1,2,3,4,5]
Length=int(raw_input("length of possible numbers required"))
#This is for length of 3 chars
for i in itertools.product(var,var,var):
print i[0]+i[1]+i[