Python Merge Items From Two List
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
Solution 1:
array[start_index:end_index] gives you a slice, a sub-list of the list it's applied on. In this case, you want to get a single item. Try the following code:
for j in range(4):
    print"%s%s" % (md_array[j], y_array[j])
You can read more about slicing and indexes on documentation for lists.
Solution 2:
print"".join("[%s%s]"%t for t in zip(md_array, y_array))
Post a Comment for "Python Merge Items From Two List"