Define function to intersect Strings and lists,intersectstrings,def intersec
Define function to intersect Strings and lists,intersectstrings,def intersec
def intersect(seq1, seq2): res = [] # start empty for x in seq1: # scan seq1 if x in seq2: # common item? res.append(x) # add to end return ress1 = 'SPAM's2 = 'SCAM'print intersect(s1, s2) # stringss1 = [1,2,3,4,5]s2 = [3,4,5,6,7]print intersect(s1, s2) # list
- Function returns another function,functionreturns,def
- Introducing globals(),introducingglobals,# globals()
- String indexing: from front or end,indexingfront,S = '
- Handling I/O Errors,handlingerrors,# shows how
- Reads a single line from the file,readssingle,f=open('
- Check a user name and PIN code,checkpin,database = [
热门文章:
相关内容
- Function returns another function,functionreturns,def knights(
- Introducing globals(),introducingglobals,# globals()
- String indexing: from front or end,indexingfront,S = 'spam'pr
- Handling I/O Errors,handlingerrors,# shows how
- Reads a single line from the file,readssingle,f=open('/tmp
- Check a user name and PIN code,checkpin,database = [
- Using the break statement in a for structure.,statementstructure,fo
- Dictionary key membership test alternative,,d2 = {'spam'
- Change .py files to use 4-space indents.,.pyindents,'''PYTHON SO
- Join a list,joinlist,li = ['a', '
评论关闭