Hey guys, I've been playing around all morning trying to get this list to be done programmatically, ie work for any number.

I've tried the following but it doesn't give the correct result:

a = [ "is", "cool"]
b = ["Peter", "James", "John"]
c = []

for k in a :
    print a
    b.append(a)
c.append(b)
print c

that gives the following results:

[['Peter', 'James', 'John', ['is', 'cool'], ['is', 'cool']]]

However thats not what I'm after. I'm trying to obtain something like this:

[ [ [ 'Peter' [ 'is' , 'cool'] ] [ 'James' [ 'is', 'cool',] ] ] ]

Can anyone shine any light onto this?

Cheers

Append everything to c

a = [ "is", "cool"]
b = ["Peter", "James", "John"]
c = []

for name in b:
   c.append( [name, a]  )
print c

[['Peter', ['is', 'cool']], ['James', ['is', 'cool']], ['John', ['is', 'cool']]]
commented: very nice solution +3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.