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 trialOszkár Fehér
Treehouse Project ReviewerCan someone please explain this.
So I made this line of code in my editor to be simple as possible without using another for block and it returns the email with letters changed. My question is why is not accepted? Just because the quiz mentions the for loop or because it's the code is not okey? I tried to pass the quiz in my way and i came up with this. Thank you.
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)
{% macro hide_email(User) %}
<p>{{ User.email.replace(User.email.split('@')[0][1:], "*" * len(User.email.split('@')[0][1:])) }}</p>
{% endmacro %}
1 Answer
Chris Freeman
Treehouse Moderator 68,454 PointsExcellent novel solution idea!! You are very close to correct. The len()
function is not available in the template language. Instead use the length
filter:
{% macro hide_email(User) %}
<p>{{ User.email.replace(User.email.split('@')[0][1:], "*" * (User.email.split('@')[0][1:] | length)) }}</p>
{% endmacro %}
Oszkár Fehér
Treehouse Project ReviewerOszkár Fehér
Treehouse Project ReviewerYey. so my idea was okey i just used something from python. Thank you Chris.
Thank you
Chris Freeman
Treehouse Moderator 68,454 PointsChris Freeman
Treehouse Moderator 68,454 PointsThis is the first time I've seen this approach used on this challenge! Kudos to you!