Question: Create a program, that checks if inputs are a valid password and encrypt it. On the first line you will receive a number that indicates

Create a program, that checks if inputs are a valid password and encrypt it. On the first line you will receive a number that indicates how many inputs you will receive on the next lines.

 

A password is valid when:

It starts with a group of symbols and ends with the same symbols(the same length) – All symbols are possible

There is a greater sign (“>” ) after the first group and a less than sign (“<”) before the last one.

In between the greater than sign and the less than sign there are four groups(each of three character), separated by pipe(“|”)

The first group consists only of numbers

The second group only lower case letters

The third one only upper case letters

The fourth one all symbols except “<” and “>”

Example for a valid message:

“$$$>312|dfe|KFE|@#<$$$”

You must check if the password is valid and if it is encrypt it, if it isn’t print the following message: “Try another password!”

Encrypting a password means to take all numbers, letters and symbols from the middle for groups and concatenate them. After successful encrypt, print it in the following format: “Password”: {encrypted password}”

 

Input: On the first line -n- the count of inputs.

 

 

On the next lines – input that you have to check if it has a valid password.

 

 

 

 

 

Output: Print all results from each input, each on a new line.

 

 

 

INPUT

Output

3

##>00|no|NO|!!!?<###

##>123|yes|YES|!!!<##

$$<111|noo|NOPE|<<>$$

 

Try another password!

Password: 123yesYES!!!

Try another password!

Comments

The first one doesn’t start and end with the same amount of “# and the count of characters in each group is different than 3. The second one is correct. The third one uses the wront “<” and “>” and the group containing “<<” can contain everything except “<” and “>”

 

 

INPUT

Output

 

 

5

aa>111|mqu|BAU|mqu

()>111!aaa!AAA!^&*<()

o>088|abc|AAA|***

asd>asd|asd|ASD|asd

*>088|zzzz|ZzZ|123<*

Try another password!

Password: 123yesYES!!!

Try another password!

 

 

 

 

 

 

 

 


Step by Step Solution

3.36 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres a Python program that checks if inputs are valid passwords and encrypts them according to the ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!