Why is the string split into characters in python

  python

The following is the code I wrote:

def comb(self, rows, cols):
return [s+t for s in a for t in b]

if rows & columns values are
rows = [‘abc’,’efg’]
cols = [‘123′,’456’]

expected output was [‘abc123′,’abc456,’efg123′,’efg456’]
program output was [‘a1’, ‘a2’, ‘a3’, ‘b1’, ‘b2’, ‘b3’, ‘c1’, ‘c2’, ‘c3’]

I am new to python programming. Could you help me understand what is happening. I already fixed the output but I would like to understand why this happened?

Source: Python Questions

LEAVE A COMMENT