As the title suggests, it's a simple function that creates a list with elements up to 3 digits. I would be grateful if you could point out any mistakes or better ways.
def generate_primes():
"""
Generate a list of prime numbers up to 3 digits.
:return:List of prime numbers up to 3 digits
"""
primes = []
for i in range(2,1000):
flag = True
for j in range(2,i):
if i%j == 0:
flag = False
if flag:
primes.append(i)
return primes
Recommended Posts