importitertoolsitertools.combinations(array,x)# array choose x
forcombinitertools.combinations(array,x):# do stuff
itertools.permutations(arr,x)# permutation
forcombinitertools.permutations(array,x):# do stuff
importrepattern=r'(\d{3})-\d{3}-\d{4}'text="Hello, my name is Goku. My number is 811-910-9324. My son's number is 643-948-2345"phoneNumRegex=re.compile(pattern)matches=phoneNumRegex.search(text)matches.group()#"811-910-9324"
matches=re.search(pattern,text)matches.group()#"811-910-9324"
matches.group(0)#["811", "643"] because we put parenthesis around the first \d
phoneNumRegex.findAll(text)#["811-910-9324", "643-948-2345"]
re.findAll(pattern,text)#["811-910-9324", "643-948-2345"]