user3496161
user3496161

Reputation: 1

perform join python returns a "none"

my "output" seems to populate fine however when I perform the join I get "none returned.

Any ideas?

def englishify_sentence(s):
    """English"""
    words = s.lower()
    words = words.split()# splits sentence into individual words
    output = []

    for i in range(len(words)):
        if words[i].endswith("way"):
            opt1 = words[i][:-3]
            letters = list(opt1)#breaks given word into individual letters
            translate = ("("+opt1+" or "+"w"+opt1+")")
            output.append(translate)
        else:
            opt2 = words[i][:-2]
            opt2_letters = list(opt2)#breaks given word into individual letters
            first_letter = (opt2_letters.pop(-1))
            opt3 = words[i][:-3]
            translate2 = (first_letter+opt3)
            output.append(translate2)
            english = " ".join(output)#removes speech marks and creates a "real" word
    print(output)

english = englishify_sentence("oday ouyay antway anway eggway")
print(english)

Upvotes: 0

Views: 90

Answers (2)

QuantumSwordsman
QuantumSwordsman

Reputation: 21

Is it the print(output) that's giving you a none or the print(english)?

Upvotes: 0

Ignacio Vazquez-Abrams
Ignacio Vazquez-Abrams

Reputation: 798456

You forgot to return the value.

return english

Upvotes: 2

Related Questions