1. Prime Numbers

Function that returns a list of all prime numbers up to a given number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. For example, 2, 3, 5, 7, and 11 are prime numbers.

image

(as a beginner in Python, Mr. Mosh tutorials is very helpful and easy to understand. Thank You!)

As beginner to understand the prime numbers code

def prime_numbers(num):
    lists = []
    for n in range(1, num+1):
        if n<=1:
            continue
        is_prime = True
        for i in range(2, int(n/2)+1):
            if n % i == 0:
                is_prime = False
                break
        if is_prime:
            lists.append(n)
    return lists