I am just starting pset7 and I thought I had fully completed register, but I keep getting an invalid syntax error on this line:
if not result:
I am really confused as this is a really simple line and copied directly from the walkthrough. I have tried everything and cannot figure out this error! Thanks for all the help in advance!
Here is my code for register:
@app.route("/register", methods=["GET", "POST"])
def register():
"""Register user."""
# get username/password
#<input name= "name", password= "password", password_confirmation= "password_confirmation"
if request.method == "POST":
#if field is blank
# print apology
if not request.form.get("username"):
return apology("you must provide a username :(")
elif not request.form.get("password"):
return apology("you must provide a password :(")
#check if passwords match
elif request.form.get("passwordconfirmation") != request.form.get("password"):
return apology("you must provide a password confirmation the same as your password!!!")
#store values in database
result = db.execute("INSERT INTO users (username, hash) \
VALUES(:username, :hash)", \
username=request.form.get("username"),\
hash=pwd_context.encrypt(request.form.get("password"))
#db.execute failure
if not result:
return apology("please pick a new username")
#log user in
session["user_id"] = result
return redirect(url_for("index"))
else:
return render_template("register.html")