I'm new to Python.
I stumped upon with one of this comprehension
print([[i+j for i in "abc"] for j in "def"])
Could you please help me convert the comprehension in for loop?
I'm not getting the desired result by for loop:
list = []
list2 = []
for j in 'def':
for i in 'abc':
list.append(i+j)
list2 = list
print (list)
the above is my try with for loop. I' missing something. Below should be the desired result in for loop that i want.
([[‘ad’, ‘bd’, ‘cd’], [‘ae’, ‘be’, ‘ce’], [‘af’, ‘bf’, ‘cf’]])
which I believe is a matrice.
Thanks in advance.