Question

Write a Python function fun8(k) that gets list of strings k as passwords and returns the...

Write a Python function fun8(k) that gets list of strings k as passwords and returns the valid passwords in list format. Criteria for checking passwords:

1.) At least 1 letter between [a-z]

2.) At least 1 letter between [A-Z]

3.) At least 1 number between [0-9]

4.) At least 1 character from [$#@]

5.) Minimum length of transaction password: 6

6.) Maximum length of transaction password: 12

7.) No spaces

Example:

>>>lst=["ABd1234@1", "a F1#,2w3E*", "2We3345"]

>>>fun8(lst)

[ABd1234@1]

*****We are a 100 level intro to computer science class, please don't use anything overly complex/advanced.

0 0
Add a comment Improve this question Transcribed image text
Answer #1
def fun8(lst):
    result = []
    for x in lst:
        hasLower = False
        hasUpper = False
        hasDigit = False
        hasSpecial = False
        hasNoSpace = True
        if(len(x)>=6 and len(x)<=12):
            for i in x:
                if(i.islower()):
                    hasLower = True
                if(i.isupper()):
                    hasUpper = True
                if(i.isdigit()):
                    hasDigit = True
                if i in "$#@":
                    hasSpecial = True
                if(i == ' '):
                    hasNoSpace = False
            if(hasLower and hasUpper and hasDigit and hasSpecial and hasNoSpace):
                result.append(x)
    return result

# Testing
lst=["ABd1234@1", "a F1#,2w3E*", "2We3345"]
print(fun8(lst))

['ABd1234@1']

Add a comment
Know the answer?
Add Answer to:
Write a Python function fun8(k) that gets list of strings k as passwords and returns the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PYTHON 1.Guessing many passwords: Write a function called guess_passwords. It doesn't take any arguments. It should use the function guess, trying out as many possible passwords as possible. Here...

    PYTHON 1.Guessing many passwords: Write a function called guess_passwords. It doesn't take any arguments. It should use the function guess, trying out as many possible passwords as possible. Here are some methods you might try: Try out a hardcoded list of strings that you think people might use as passwords. Try out all words in the word file. Try out all character combinations of length 4 or less (or more if you don't mind waiting). Try out combinations of words...

  • PYTHON CODE ONLY PLEASE, AND COMMENT IN SCRIPT TO SHOW STEPS (post copy-ready text code, and also...

    PYTHON CODE ONLY PLEASE, AND COMMENT IN SCRIPT TO SHOW STEPS (post copy-ready text code, and also a screenshot of code running) You work for an on-line game site. Your job is to develop a program that accepts a user name and password. Write a Python script that prompts users for a user name and password. a. The user name should be at least 6 characters long and is stored in a list such that it 1. can't be used...

  • In python Exercise 4 (graded) Write a function "passValidate" that takes a string "s" and checks...

    In python Exercise 4 (graded) Write a function "passValidate" that takes a string "s" and checks the validity of string as a password Validation Rules: At least 1 lowercase letter between [a-z] and 1 upper case letter between [A-Z]. At least 1 number between [0-9 At least 1 character from [$#@]. Minimum length 6 characters. Maximum length 16 characters. CS103-Lab 13 Page 3 of 3 Sample Input: s"Uab@2762" Sample Output: True

  • solve with python Write a recursive function recStringWithLenCount() that takes a one-dimensional list of strings as...

    solve with python Write a recursive function recStringWithLenCount() that takes a one-dimensional list of strings as a parameter and returns the count of strings that have at least the length of second parameter passed into the function that are found in the list. Recall that you can determine whether an item is a string by writing type(item) == str. The only list functions you are allowed to use are len(), indexing (lst[i] for an integer i), or slicing (lst[i:j] for...

  • Write a Python function fun3(e) to update a list of numbers e such that the first...

    Write a Python function fun3(e) to update a list of numbers e such that the first and last elements have been exchanged. The function needs to also return multiplication of elements of e. You should assume that the list e has at least 2 elements. Example: >>>lst = [4, 1, 2, -1] >>>fun3(list) -8 >>>lst [-1, 1, 2, 4] *We are an intro to CS class so please do not use anything too advance or fancy. Stick to basics. Right...

  • Write a program that inputs a string from the user representing a password, and checks its...

    Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...

  • language is python Write a function named subsetStrings that has two inputs, a list of strings...

    language is python Write a function named subsetStrings that has two inputs, a list of strings and an integer n. Your function should use a single list comprehension to create a new list containing the first n characters of each string in the input list if the length of the individual string is at least n (strings that are too short should be skipped). Your function should return the new list ex: inputList 'Frederic, 'powerade', 'spring break, 'pen'] and n-4...

  • **DO IT AS PYTHON PLEASE** The Trifid Cipher General Problem Description The Trifid cipher (not to be confused with the...

    **DO IT AS PYTHON PLEASE** The Trifid Cipher General Problem Description The Trifid cipher (not to be confused with the creatures from the classic science-fiction film "The Day of the Triffids") is an algorithm that enciphers a plaintext message by encoding each letter as a three-digit number and then breaking up and rearranging the digits from each letter's encoded form. For this assignment, you will create a set of Python functions that can encode messages using this cipher (these functions...

  • python . Write the function poker_hand that takes a list of exactly five distinct Card objects...

    python . Write the function poker_hand that takes a list of exactly five distinct Card objects as an argument, analyzes the list, and returns one of the following strings that describes the hand: "Four of a kind' (four cards of the same rank) 'Full house' (three cards of one rank, and two cards of a different rank) . 'Flush' (five cards of the same suit) 'Three of a kind' (exactly three cards of the same rank) • 'One pair' (at...

  • Write the following functions, as defined by the given IPO comments. Remember to include the IPO...

    Write the following functions, as defined by the given IPO comments. Remember to include the IPO comments in your submission. Be sure to test your code -- you can use the examples given for each function, but you should probably test additional examples as well -- and then comment-out or remove your testing code from your submission!. We will be testing your functions using a separate program, and if your own testing code runs when we load your file it...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT