Hello Bernd,

My comments below, interleaved with yours.

On Sun, Mar 11, 2018 at 04:23:02PM +0100, Bernd Hewener wrote:

> Functions for reading in the number and finding the primes are working 
> alright (of Course, finding primes up to ½ Number would suffice).

Actually you only need to go up to square root of the number.

> Still, the function for finding the factorization itsel does not work. 
> I am not sure, but the number i running through the primes for 
> checking does not seem to work properly.

What do you mean, does not work? In what way?

When you run the code, what does it do?

Some further comments:

> def readin():
>     print ("Readin")
>     while True:
>         num = input("Please enter a positive integer n for prime 
> factorization. ")
>         try:
>             n = int(num)
>             return n
>         except ValueError or num < 1:
>                 print("Please enter a _positive_ integer!")
>         else:
>             break

That code doesn't actually do what you think it does. In fact, it is an 
accident that it works at all!

The problem is the line

    except ValueError or num < 1

which does *not* catch a ValueError and check that num is less than one. 
Instead, it evaluates to just catching ValueError. So it never checks 
that the entered number is positive.


Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:

Reply via email to