Python Forum
Syntax "for" loop, "and", ".isupper()", ".islower", ".isnum()"
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Syntax "for" loop, "and", ".isupper()", ".islower", ".isnum()"
#1
Hello! I'm trying to run any code but my Kernel needs to be re-started all the time (I have Windows, is that related?), besides I have syntax problems. If someone can help me, I would really appreciate it!

#3. A website requires a user to input username and password to register. 
#   Write a program to check the validity of password given by user. 
#   Following are the criteria for checking password:
​
#  1. At least 1 letter between [a-z] 
#  2. At least 1 number between [0-9] 
#  3. At least 1 letter between [A-Z]
#  4. At least 1 character from [$#@]
#  5. Minimum length of transaction password: 6 
#  6. Maximum length of transaction password: 12
​
#Hint: In case of input data being supplied to the question, 
#it should be assumed to be a console input.

name=str(input('Name: ', ))
​
password=str(input('Enter a password with: At least 1 capital or lower case letter, 1 number and 1 of these characters: $#@. The password must have between 6 and 12 characters ',  ))
Error:
File "<ipython-input-2-97a716fd38be>", line 6 if not password.isupper() and not password.islower() and not password.isnum() ^ SyntaxError: invalid syntax
characters=list(password)
special_characters=['$', '#','@']
Error:
NameError Traceback (most recent call last) <ipython-input-3-a33fe6ef79e7> in <module> ----> 1 characters=list(password) 2 special_characters=['$', '#','@'] NameError: name 'password' is not defined
if not password.isupper() and not password.islower() and not password.isnum() 
and  character in special_charaters and len(password)>=6 and len(password)<=12
print('Valid password')
else print ('Invalid password')
password=str(input('Enter a password with: At least 1 capital or lower case letter, 1 number and 1 of these characters: $#@. The password must have between 6 and 12 characters ',  ))
Reply


Messages In This Thread
Syntax "for" loop, "and", ".isupper()", ".islower", ".isnum()" - by dcardonaa - Sep-04-2019, 10:11 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Syntax Error: Invalid Syntax in a while loop sydney 1 4,194 Oct-19-2019, 01:40 AM
Last Post: jefsummers
  SyntaxError: Invalid syntax in a while loop ludegrae 3 14,993 Dec-18-2018, 04:12 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020