Skip to content

Functions - Prime Check in Python3 Returns Multiple Values #43

Description

@paper-skyline

In Python3.7, entering this function and passing the number 5 to the function results in multiple return values of "True". What's causing that?

def is_prime(num):
    '''
    Naive method of checking for primes. 
    '''
    for n in range(2,num):
        if num % n == 0:
            print 'not prime'
            break
    else: # If never mod zero, then prime
        print 'prime'
>>> is_prime(5)
prime
prime
prime

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions