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

Python help - Correct the import style

Correct the import style

import os, sys, logging
from re import match, search

http://teamtreehouse.com/library/write-better-python/cleaner-code/imports

Dave McFarland
Dave McFarland
Treehouse Teacher

Hi Lyric

To put code into a forum post use triple back ticks -- ``` — around the code. I fixed your code here, but in the future here's a forum discussion that describes how to add HTML, CSS, JavaScript or other code to the forum: https://teamtreehouse.com/forum/posting-code-to-the-forum

3 Answers

Megan L
Megan L
2,906 Points

This website has helped me with the challenge. pep8online.com/checkresult.

The key to the challenge is that imports must be on their own separate lines. If you are importing from another package or module they can be on the same line. But for this challenge, you need to have a new line afterward. I hope this helps someone with the challenge cause all I was missing was the new line and surprisingly no one posted a solution for this challenge yet.

import os
import sys
import logging
from re import match, search
Kenneth Love
STAFF
Kenneth Love
Treehouse Guest Teacher

The video covers how importation should be, so does the actual PEP 8 documentation. What did you try that failed?

Additionally here is the link to the PEP 8 rules for imports: http://legacy.python.org/dev/peps/pep-0008/#imports