Rachel M.

asked • 02/27/23

count list python

Write a function named passwords(my_list), which takes a list of passwords as an argument and returns the list containing the number of digits, number of letters and number of other characters of every password in the given list. (Hint: make sure your code removes all leading and trailing blank spaces from the passwords, if any)

Examples:

passwords(['123pass', ' pass@123', '  weakpass  ']) returns [ [3,4,0] , [3,4,1] , [0,8,0] ] ->a list of lists (2D list)

Explanation: the 1st password '123pass' has 3 digits, 4 letters and 0 other characters, so the first element of the final returned list is [3,4,0]; Similarly, the 2nd password ' pass@123' has 3 digits, 4 letters and 1 other character, so the second element of the returned list is [3,4,1]; The 3rd password in the list '  weakpass  ' has 0 digits, 8 letters and 0 other characters, so the third element of the returned list is [0,8,0].

passwords([ 'p@$$wor6' , '  not()404']) returns [ [1,4,3] , [3,3,2] ]

passwords(['123456789']) returns [ [9,0,0] ]

1 Expert Answer

By:

Baker S. answered • 02/27/23

Tutor
5 (2)

Stanford CS Major with 5+ years teaching and tutoring experience

Rachel M.

I know char = characters, I'm having trouble figuring out what digit and letters would translate to in a python script
Report

02/28/23

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.