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

Diallo West
Diallo West
15,069 Points

I'm not sure why this code isn't working in the Macro challenge?

When I execute the code, I'm getting the desired response, however, I'm still getting an error message. Any help would be appreciated.

lunch.py
from flask import Flask, render_template

app = Flask(__name__)

@app.route('/')
def index():
    class User:
        email = None
    user = User()
    user.email = 'kenneth@teamtreehouse.com'
    return render_template('user.html', user=user)
templates/macro.html
{% macro hide_email(user) %}
    {% with name, domain = user.email.split('@') %}
      {{ name[0] }}{% for n in name[1:] %} * {% endfor %} {{'@' +  domain}}
    {% endwith %}
{% endmacro %}

3 Answers

Ryan S
Ryan S
27,276 Points

Hi Diallo,

It is tough to tell from the error message, but the problem is that there is a single space between each character up to the @ symbol. If you adjust your macro to get rid of the spaces then it will work.

Diallo West
Diallo West
15,069 Points

Thank you so much. I couldn't figure out why it wouldn't pass. Thanks

Francis Wanyonyi
Francis Wanyonyi
6,768 Points

Hi Diallo,

Thanks for asking this question. Your code is sweet. This question had me stumped.