hw4_part1
.py
keyboard_arrow_up
School
Rensselaer Polytechnic Institute *
*We aren’t endorsed by this school
Course
1100
Subject
Information Systems
Date
Dec 6, 2023
Type
py
Pages
2
Uploaded by MinisterSeahorse3653
import hw4_util
lists_count = hw4_util.get_number_of_password_lists()
com_list = str(input('Select the list of common passwords by entering a number
between 0 and {:.0f} => '.format(lists_count-1)))
print(com_list)
word= str(input('Enter a password => '))
print(word)
passwords = hw4_util.get_password_list(int(com_list))
yes = []
#Rule 1
is_long_enough = len(word) <= 25 and len(word) >= 4
first_letter= word[0].islower() or word[0].isupper()
if is_long_enough and first_letter:
print('Rule 1 is satisfied')
yes.append('r1')
else:
print('Rule 1 is not satisfied')
#Rule 2
passwd = word.lower()
counter = 0
for i in passwords:
if passwd == i:
counter +=1
else:
counter +=0
if counter > 0:
print('Rule 2 is not satisfied')
else:
print('Rule 2 is satisfied')
yes.append('r2')
#Rule 3
symbol1 = word.count('@')
symbol2= word.count('$')
total = symbol1 + symbol2
symbol3= word.count('%')
if total == 0 or symbol3 > 0:
print('Rule 3 is not satisfied')
else:
print('Rule 3 is satisfied')
yes.append('r3')
#Rule 4
upper= word.isupper()
lower= word.islower()
if upper is False and lower is False or word.count('1') > 0 or word.count('2') > 0
or word.count('3') > 0 or word.count('4') > 0:
print('Rule 4 is satisfied')
yes.append('r4')
else:
print("Rule 4 is not satisfied")
#Rule 5
i = 0
t = True
for i in range(len(word)-1):
if (word[i].isupper()) and (word[i+1]) == '_':
t = False
else:
t = True
if word.islower() or word.isdigit():
t = False
if t == False:
print('Rule 5 is satisfied')
yes.append('r5')
else:
print('Rule 5 is not satisfied')
#Rule 6
i = 0
t = True
for i in range(len(word)):
if word[i].isdigit() and word[i] >= '5':
t = False
if word.count('5') + word.count('6') + word.count('7') + word.count('8') +
word.count('9') >= 1:
t = False
else:
t = True
if t == False:
print('Rule 6 is not satisfied')
else:
print('Rule 6 is satisfied')
yes.append('r6')
#password
if len(yes) == 6:
print('The password is valid')
elif yes.count('r1') == 0:
print('The password is not valid')
elif yes.count('r1') == 1 and len(yes) < 6:
print('A suggested password is:', word[0:3]+'42'+word[-3:])
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
- Access to all documents
- Unlimited textbook solutions
- 24/7 expert homework help