Yes. Some of the comments I received used zip, but I didn't know how to use it or how it behaves, so check it roughly.
op.py
#!/usr/bin/env python
# -*- coding:utf-8 -*-
#from __future__ import print_function
import sys
import io
import re
import math
####Memory usage and operating time check preparation
from guppy import hpy
import time
start = time.clock()
h = hpy()
####Up to here
i1=[1,2,3,4,5]
i2=[1,2,3,4,5]
z = zip(i1,i2)
print z
print type(z)
print z[0]
i1=[1,2,3,4,5]
i2=[3,4,5]
z = zip(i1,i2)
print z
s1=['dog','cat','bird','kame']
s2=['dog','cat','bird','kame']
z = zip(s1,s2)
print z
s1=['dog','cat','bird','kame']
s2=['dog','kame']
z = zip(s1,s2)
print z
#print m
####Memory usage and operating time output
end = time.clock()
print (h.heap())
print (end - start)
result [(1, 1), (2, 2), (3, 3), (4, 4), (5, 5)] <type 'list'> (1, 1) <type 'tuple'> [(1, 3), (2, 4), (3, 5)] [('dog', 'dog'), ('cat', 'cat'), ('bird', 'bird'), ('kame', 'kame')] [('dog', 'dog'), ('cat', 'kame')]
Hmmm, I wonder if (x, y) or something like a dictionary is put in a list and returned. Is it the remainder of the one with the smaller number of elements and the one with the larger number? Seems to be ignored. I can't think of a way to use it at all, so I can't really understand how to use it unless I imitate what other people are writing and check the behavior.
Recommended Posts