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 Write Better Python Cleaner Code Imports

Robert Young
Robert Young
1,391 Points

Correct the import style

I dont see why this is wrong?

starter.py
import os
import sys
import logging
from re
import match
import search

5 Answers

It should look like this:

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

For some reason it requires you to have an empty space at the end as well. You also need to specify where you import match and search from.

Robert Young
Robert Young
1,391 Points

thanks he i must have missed out on what from re is

Megan L
Megan L
2,905 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

I'm still NOT getting it!

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

Maybe coding isn't for me

I still don't know how to eliminate whitespaces but somehow I had to play around with it...must be magic or the luck of the draw idk......finally aced challenge