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 Build a Social Network with Flask Making Strong Users Bcryptkeeper

set_password that takes a User and a string for their password. Hash the password, set the User.password attribute to th

set_password that takes a User and a string for their password. Hash the password, set the User.password attribute to the hashed password, and return the User. ... why would task 1 be no longer passing? please help =)

utils.py
from flask.ext.bcrypt import check_password_hash
from flask.ext.bcrypt import generate_password_hash


def set_password(User, "string"):
  generate_password_hash("string")
  User.password = generate_password_hash("string")
  return User

2 Answers

Dan Johnson
Dan Johnson
40,532 Points

When defining the method body you just want to give arguments a name, not just a literal value:

def set_password(user, password):
  #...

You can also remove the first line of your function. Calling generate_password_hash without storing the return value won't do much for you.

If you did want your function arguments to have default values (you wouldn't for this challenge) you can do this:

def my_func(my_val="default value"):
  print(my_val)

If my_func is called with no arguments passed, it will print, "default value".

=D thanks.