Python3 solution - create two lists and merge

class Solution:
    # @param A : head node of linked list
    # @param B : integer
    # @return the head node in the linked list
    def partition(self, A, B):
        #first  and second are two list having nodes of values <B and >=B. t1 is head of first list
        first, second, t1 = None, None, None
        head = A
        while head is not None:
            if head.val < B:
                if first is None:
                    first = head
                    t1 = first
           =  head
                    first =
                if second is None:
                    second = head
                    # t2 is head of second list
                    t2 = second
           = head
                    second =
            head = = None
        # check if there are no elements less than B
        if t1 is not None:
   = t2
            return t1
            return t2