Problem in calculating prime numbers in python I'm a noob in programming. I was asked to code a program that can calculate prime numbers. So i coded as provided below. But it prints all the Odd Numbers instead of Prime Numbers. I think the Value start is not being divided by all the integers in the range (2,Startnumber). It just prints all the odd numbers.

startnumber=int(raw_input("Enter a number: "))
start=2
while start&lt;=startnumber:
    for divisor in range(2,startnumber):
        if start%divisor==0:
            break
        else:
            print start
            break
    start=start+1
There is no need to keep for loop in the while as while is doing the job of for,
assuming that your program tests whether the startnumber is prime or not.

using of break in else will terminate your loop once it checks that its not divisible by 2 [ the first divisor] . so break shouldn't be used there in else block as you want to test for numbers above 2.

We can while - else or for-else to solve your problem. 
the code below shows the representation of your problem in while - else:

startnumber=int(raw_input("Enter a number: "))
start=2
while start&lt;startnumber:

    if startnumber%start==0:
        print str(startnumber)+" is not a prime."
        break 
    start=start+1
else:
    print str(startnumber)+" is a prime."


same code with for -else would be :

startnumber=int(raw_input("Enter a number: "))
start=2
for number in range(2,startnumber):

    if startnumber%start==0:
        print str(startnumber)+" is not a prime."
        break 
    start=start+1
else:
    print str(startnumber)+" is a prime."