sneakysnake sneakysnake - 1 year ago 127
Python Question

Fixing My Base 10 to Binary Converter

Right now, I have a base 10 to base 2 converter that works, however it always prints none at the end of every conversion.

def binary_recursion(base_ten):
global base_two
if base_ten==0:
while base_ten//2**c>1:
if c==0:

I tried returning base_two as opposed to printing it, but that doesn't return a number, it also just returns None. Can anyone help me pinpoint my mistake?

Answer Source
def node(document_info, next_node):
    return {'data': document_info, 'next': next_node}

def insert(head, new_document_info):
    #insert new document into the linked list head
    #returns the head of the modified list
    if head is None:
        return node(new_document_info, None)
    if new_document_info[1] <= head['data'][1]:
        return node(new_document_info,  head)
    head['next'] = insert(head['next'], new_document_info)
    return head    

Here's a slightly modified way of doing insertion sort, from my answer to you last question. You would start with head = None and then every time you add a print job do head = insert(head, document_info). Or after collecting all of your print jobs do something like

head = None
for document_info in list_queue:
    head = insert(head, document_info)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download