Skip to main content
deleted 9 characters in body
Source Link

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

You don't need to explicitly inherit from object if you're writing python3 code that doesn't require to be python2 compatible. This happens implicitly in python3. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def append_multipleextend(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

Additionally, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Lastly, I don't like using next as a variable, because it's already built-in, but that's not going to cause any trouble here.

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

You don't need to explicitly inherit from object if you're writing python3 code that doesn't require to be python2 compatible. This happens implicitly in python3. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def append_multiple(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

Additionally, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Lastly, I don't like using next as a variable, because it's already built-in, but that's not going to cause any trouble here.

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

You don't need to explicitly inherit from object if you're writing python3 code that doesn't require to be python2 compatible. This happens implicitly in python3. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def extend(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

Additionally, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Lastly, I don't like using next as a variable, because it's already built-in, but that's not going to cause any trouble here.

added 66 characters in body
Source Link

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

Just omit theYou don't need to explicitly inherit from object if you're writing python3 code that doesn't require to be python2 compatible. This happens implicitly in python3. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def append_multiple(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

Additionally, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Lastly, I don't like using next as a variable, because it's already built-in, but it'sthat's not going to cause any trouble here.

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

Just omit the object if you're writing python3 code that doesn't require to be python2 compatible. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def append_multiple(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

Additionally, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Lastly, I don't like using next as a variable, because it's already built-in, but it's not going to cause any trouble here.

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

You don't need to explicitly inherit from object if you're writing python3 code that doesn't require to be python2 compatible. This happens implicitly in python3. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def append_multiple(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

Additionally, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Lastly, I don't like using next as a variable, because it's already built-in, but that's not going to cause any trouble here.

added 129 characters in body
Source Link

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

Just omit the object if you're writing python3 code that doesn't require to be python2 compatible. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def append_multiple(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

LastlyAdditionally, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Lastly, I don't like using next as a variable, because it's already built-in, but it's not going to cause any trouble here.

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

Just omit the object if you're writing python3 code that doesn't require to be python2 compatible. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def append_multiple(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

Lastly, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Great job, looks really good! A few minor thoughts, on top of the existing answers:

class LinkedList(object):
    ...

Just omit the object if you're writing python3 code that doesn't require to be python2 compatible. You've already done this for Node. Check out new style vs. old style classes if you want to learn more about this.

class LinkedList:
    ...

Moreover, you could define a function to add multiple values, such as:

def append_multiple(self, vals):
    for val in vals:
        self.append(val)

You can also use that in your __init__ if initial values are provided.

Additionally, you could define an __iter__ function that implements a generator. This could help you with tasks for which you don't want to use to_list() and allocate the memory for a list.

def __iter__(self):
    curr = self.head
    while curr:
        yield curr
        curr = curr.next

Lastly, I don't like using next as a variable, because it's already built-in, but it's not going to cause any trouble here.

Source Link
Loading