A function that generates a list with up to 3 prime numbers as elements

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

A function that generates a list with up to 3 prime numbers as elements
I tried to create a list of prime numbers with python
How to print characters as a table with Python's print function
[Python] Solution to the problem that elements are linked when copying a list
Convert a slice object to a list of index numbers
Make a function to describe Japanese fonts with OpenCV
I tried to make a generator that generates a C # container class from CSV with Python
Create a web application that recognizes numbers with a neural network
Create a Mastodon bot with a function to automatically reply with Python
Generate a password that is easy to remember with apg
Try to bring up a subwindow with PyQt5 and Python
How to display a list of installable versions with pyenv
[Golang] A program that determines the turn with random numbers
How to call a function
Determine prime numbers with python
I want to use a wildcard that I want to shell with Python remove
[Road to Python Intermediate] Call a class instance like a function with __call__
How to compare lists and retrieve common elements in a list
[Introduction to Python] How to split a character string with the split function
[Python 3.8 ~] How to define a recursive function smartly with a lambda expression
[Python] A memo that I tried to get started with asyncio
If you give a list with the default argument of the function ...
How to get a list excluding elements whose index is i ...?
A script that returns 0, 1 attached to the first Python prime number
Create a poster with matplotlib to visualize multiplication tables that remember multiplication
Pass a list by reference from Python to C ++ with pybind11
[Python] A program that rotates the contents of the list to the left
[Python] How to create a dictionary type list, add / change / delete elements, and extract with a for statement
Introduction and usage of Python bottle ・ Try to set up a simple web server with login function