[Tutor] How can I replicate a list in a for loop

Suresh Nagulavancha suresh852456 at gmail.com
Tue Feb 3 23:51:31 CET 2015


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[2]


Here what is my problem is i am unable to replicate the list based on the user input i tried var*length but it is creating a new single list with repeated values , how can i solve this problem?? I want the same original list to be used


Thanks in advance 


More information about the Tutor mailing list