Posts

Post not yet marked as solved
3 Replies
The print is not necesary, I was cheking to see if the function works. You need to delete the lines from those function wich contain "print(n) or print(char).
Post not yet marked as solved
3 Replies
Hello Roxy,This code works for me. Please take a look and tell me what you think, maybe we can improve it. Waiting for the reply!Best regards!let tenMostCommonPasswords = [ "123456", "password", "12345678", "qwerty", "12345", "123456789", "letmein", "1234567", "football", "iloveyou"]let digits = "0123456789"let punctuation = "!@#$%^&*(),.<>;'`~[]{}\\|/?_-+= "let password = "Football1!sdnsaifinfeanf239"func doesPasswordHaveUppercase() -> Bool { for char in password { if char.isUppercase { return true }} return false}func doesPasswordHaveDigits() -> Bool { for char in digits { if password.contains(char) { return true }} return false} func doesYourPasswordHavePunctuation() -> Bool { for n in punctuation { if password.contains(n) { return true } } return false } func choosePaswword() -> String { for pass in tenMostCommonPasswords { if tenMostCommonPasswords.contains(pass) { if doesPasswordHaveDigits() == false { if doesYourPasswordHavePunctuation() == false { return "Your password: \(password) should not to be one of this passwords: \(tenMostCommonPasswords)" } } } } if doesPasswordHaveDigits() == true && doesYourPasswordHavePunctuation() == true && password.count > 16 && doesPasswordHaveUppercase() == true { return "Your password is strong enough" } return "Your password: \(password) need to contain at least one digit, at least one punctuation character, at least one regular letter and needs to have more then 16 characters"}choosePaswword()