I have the following codes:
for j in range(4):
print md_array[j:j+1]
for j in range(4):
print y_array[j:j+1]
for j in range(4):
print md_array[j:j+1]+y_array[j:j+1]
for j in range(4):
print "%s%s" % (md_array[j:j+1], y_array[j:j+1])
The results are:
['12/1/']['12/2/']['12/3/']['12/34/']
['2011']['2010']['2009']['2008']
['12/1/', '2011']['12/2/', '2010']['12/3/', '2009']['12/34/', '2008']
['12/1/']['2011']['12/2/']['2010']['12/3/']['2009']['12/34/']['2008']
BUT actually I want to output
['12/1/2011']['12/2/2010']['12/3/2009']['12/34/2008']
I tried append but failed...So what's wrong with my codes??
解决方案print "".join("[%s%s]"%t for t in zip(md_array, y_array))