Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Technical Interview Prep: Python Basics Basic Python And I Will Try To Fix You

Fix pep8 mistakes

I don't know why this isn't working, can someone help

pep.py
import datetime


def my_func():
    return 'It ran!'


sizes = ['small', 'medium', 'large']


class Tree:

    def __init__(self, size, characteristics):
        self.size = size
        self.charac = characteristics
        self.roots = True
        self.leaves = 0

    def grow_leaves(self):
        self.leaves += 1


Tree(sizes[0], {"name': 'Tulip Tree'})

4 Answers

Chris Harpe
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Chris Harpe
Python Development Techdegree Graduate 8,823 Points

I'm having the same issue... any suggestions? This won't pass the assessment and is returning the error message: Bummer: There should be 2 blanks lines after a function or class

import datetime


def my_func():
    return "It ran!"


sizes = ["small", "medium", "large"]


class Tree:

    def __init__(self, size, characteristics):
        self.size = size
        self.charac = characteristics
        self.roots = True
        self.leaves = 0

    def grow_leaves(self):
        self.leaves += 1


Tree(sizes[0], {"name":"Tulip Tree"})
Eugene Tkach
seal-mask
.a{fill-rule:evenodd;}techdegree
Eugene Tkach
Python Development Techdegree Student 1,591 Points

I'm very new to this but have some coding experience. Just started the course. Correct me if I'm wrong but have you checked your last line? It looks like your quotes are incorrect, you didn't close out your function correctly.

Yeah I forgot to fix that but that's not why it's working. It's saying to put a blank line before a method and I've tried putting blank lines everywhere. Thank you though.

Megan Amendola
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree seal-36
Megan Amendola
Treehouse Teacher

Hi Joe Wingfield

I copied the code you have above and fixed the quote error on the last line that Eugene Tkach was talking about to be:

Tree(sizes[0], {'name': 'Tulip Tree'})

The code passes. Did you make any other changes to your code?

Thank you for the help. I passed the challenge but something is confusing me. With the code above the bummer message said "add a blank line before a method", even though it should have said to fix the quote. I put the quote error there on purpose to try and see if the "blank line before a method error" would still overlap it, which it did. When I completed the code from scratch it would always say the same blank line error, but when I copy and pasted the code you provided it worked, even though I had the exact same thing you typed in, character for character. That's why I think that there might be an error with the challenge. Thank you for the help.

Lonnie Hodges Jr
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Lonnie Hodges Jr
Python Development Techdegree Graduate 8,551 Points

I was having the same problem as Eugene. I cut all of the code from the page, pasted it in my IDE, cut it in my IDE, and then pasted it back in to the Treehouse workspace which fixed the problem.