标签:
1 #!/usr/bin/env python 2 # Gets the number of primes in the list 3 4 list1 = [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 29] 5 # Get prime function . 6 def get_num(n): 7 count = False 8 for x in range(2,n-1): 9 if n % x == 0: 10 count = True 11 break 12 if not count: 13 return n 14 # Count prime 15 new_list = [] 16 for i in list1: 17 num = get_num(i) 18 if num in list1: 19 new_list.append(num) 20 print(len(new_list))
标签:
原文地址:http://www.cnblogs.com/topicjie/p/5221251.html