I have given the append function to print all the errors,but it is not getting the append.What should i do?

from flask import Flask, redirect, url_for, request, jsonify
import re
app = Flask(__name__)

@app.route('/validate/<name>',methods = ['POST', 'GET'])
def validate(name):
        error = []
        if len(name)<8:
            error.append("have atleast 8 letters")
        if re.search('[A-Z]', name) is None:
            count += 1
            error.append("have a capital letter")
        if re.search('[[email protected]#$%^&*:;?,]', name) is None:
            count += 1
            error.append("have a special character")
        if re.search('[0-9]', name) is None:
            count += 1
            error.append("have a digit")
        if re.search('^[A-Za-z]', name) is None:
            count += 1
            error.append("starts with a character")
        if count >= 1:
            return ("Make sure your password", error[0])
        if count >= 2:
            return("", "and", error[1])
        if count >= 3:
            return("", "and", error[2])
        if count >= 4:
            return("", "and", error[3])
        if count==0:
            return "Your password seems fine"

        return jsonify({'password':name})

if __name__ == '__main__':
   app.run(debug = True)

Expected output: abcd Make sure your password have atleast 8 letters and have a capital letter and have a special character and have a digit

Actual result: Make sure your password

0 Answers