PythonでThe Common Words

f:id:g_YUYUYU:20140425144540j:plain

コード2

def checkio(first,second):
	f = set(first.split(","))
	s = set(second.split(","))
	common = f.intersection(s)
	print ",".join(sorted(common))

コード1

def checkio(first,second):
	f=first.split(",")
	s=second.split(",")
	n=[]
	for i in f:
		for j in s:
			if str(i) == str(j):
				n.append(i)
	if n != []:
		x = ",".join(sorted(n))
		print x
	else:
		print ""

参考にしたサイト

一言

setは集合計算をしたいときに使う