In: Computer Science
Privacy program, lab2pr2.py Write an automated password-hiding
program that
could be used in automatic password manager. The program will first
read user
passwords, one at a time, and store them in a list. When the user
enters an empty
string (just hits enter), they are finished with the input. The
program should
then replace each password with a string of * corresponding to the
length of the
original password. As the output, the program should print the
original list and
the resulting list.
For instance, here’s the output from a sample run of your
program:
Please enter a password (press [enter] to finish): Tulane123
Please enter a password (press [enter] to finish): Bruff
Please enter a password (press [enter] to finish): LBCLBC
Please enter a password (press [enter] to finish):
[’Tulane123’, ’Bruff’, ’LBCLBC’]
[’*********’, ’*****’, ’******’]
use python
def mask(txt):
res=""
for x in txt:
res=res+"*"
return res
myList=[]
while(True):
#reading from user
word=input("Please enter a password (press [enter] to finish): ")
#if it is empty string than break loop
if(len(word)==0):
break
#appending to list
myList.append(word)
res=[]
#iterating the passwords
for x in myList:
#maskig and storing in another list
res.append(mask(x))
#printing list
print(myList)
print(res)
Note : Please comment below if you have concerns. I am here to help you
If you like my answer please rate and help me it is very Imp for me