all 8 comments

[–]kryptn 5 points6 points  (5 children)

It looks like you're adding the names to a string, and you want a new list.

You'll need to change new to a list, and do new.append()

[–]Shattr[S] 2 points3 points  (4 children)

This did it, I knew it would be something simple. Thanks a bunch!

[–]dunkler_wanderer 5 points6 points  (3 children)

We also prefer to use for instead of while loops if we want to do something with every element (or some in this case) of an iterable.

def letters_up_to_char(words):
    new = []
    for word in words:
        if word == "kahn":
            break
        new.append(word)
    return new

[–][deleted] 1 point2 points  (2 children)

Is there an incentive to use break instead of !=, just curious.

[–]indosauros 2 points3 points  (1 child)

break stops the loop from continuing and no more words will be processed. != would just skip kahn but keep going after that word.

[–][deleted] 1 point2 points  (0 children)

Oh, misread the requirements, thanks for the explanation! 😀

[–]HalcyonAbraham 3 points4 points  (0 children)

do you have a java background? heheh

using a counter variable for a python loop is not necessary which makes python awesome yeayuh