Printing all prime factors of a number input by the user
Consistency

Why is there sometimes a 1 at the end of the results?  Should it even be there, considering that 1 is not a prime number?  If you do include it in the results, why is it at the end instead of at the beginning of the list?


Enter the integer you wish to find the prime factors of: 60
[2, 2, 3, 5, 1]

Enter the integer you wish to find the prime factors of: 5
[5, 1]

Enter the integer you wish to find the prime factors of: 4
[2, 2]



Lint

PEP 8, the official style guide, specifies 4 spaces per level of indentation.  This is a strong convention for Python, where whitespace is significant.

Also, by PEP 8, primefactor() would be better named prime_factors().

It makes no sense to convert n to a float, then convert it again to an int.

import math is pointless; you never use anything in the math module.

Some of your comments are unclear.  For example:


if i&gt;=(b/2): #number is prime



… would be better written as # b is prime.

Since this is all integer arithmetic, you can prepare your code for use with Python 3 by using the // operator rather than /.

Counting loops in Python are better written using some kind of for loop in conjunction with an iterator.  Here, I recommend itertools.count(2).

Generality and organization

primefactor() would be better as a function that accepts a parameter, rather than using the global variable n.  It should definitely return a list that it created, rather than modifying a global L as a side-effect.

Why doesn't primefactor() also work for n ≤ 4?  If you organized the code properly, the caller wouldn't be responsible for handling special cases (which aren't even necessary in the first place).  There would be no need to call exit() — which you should almost never need in a properly structured program.

Flag variables, especially poorly named ones like test, are rarely desirable or necessary.  Here, you can easily eliminate the test variable by changing test=False to return L.

First rewrite

Incorporating the remarks above, and more…

from itertools import count

def prime_factors(n):
    factors = []
    for i in count(2):
        while n % i == 0:
            factors.append(i)
            n //= i
        if 2 * i &gt; n:
            return factors

n = int(raw_input('Enter the integer you wish to find the prime factors of: '))
print(prime_factors(n))


Yielding results

You can stream the results back to the caller by yielding prime factors as you find them, rather than building the entire list.

As an optimization, you can avoid considering even factors other than 2.

from itertools import chain, count

def prime_factors(n):
    for i in chain([2], count(3, 2)): # Try 2, 3, 5, 7, 9, 11, 13, 15...
        while n % i == 0:
            yield i
            n //= i
        if 2 * i &gt; n:
            return 

n = int(raw_input('Enter the integer you wish to find the prime factors of: '))
print(', '.join(prime_factors(n)))