![]() |
help - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: help (/thread-4559.html) |
help - Netanel - Aug-26-2017 l=['a','b','c'] r=[1,2,3] e=['a','b','c','d'] n=[] for i in l: for j in r: for t in e: n.append(i+str(j)+t) print nhi, i am trying to do some thing like this - to make all the posibble combintaition of values from all the lists. the broblem is that i dont know how many list i will have, its depends on the user input. so is there a way to creates multiple loops without defining then in the inital program? for i in l: for j in r: for t in e:it should be indent RE: help - kalyanben - Aug-26-2017 i think combinations or permutations method in itertools module will help you. try to read documentation and implement them. |