[Solved] How to debug this Python code? [closed]


(IS THE CODE GIVEN BELOW THE RIGHT CODE FOR THE ABOVE QUESTION WILL THIS PYTHON CODE WORK FOR THE ABOVE QUESTION?? )

ANSWARE : no , you can compare your code with my writed code , you have used unnecessary neted loops and lists and your code is not clearly unreadable

how can i solve it?

see the below code :

a= str(raw_input("enter password "))


y=['~','!','@','#','$','%','^','&','*','(',')','_','+',';','[']


if (a[0].isalpha()) and sum(c.isdigit() for c in a) and sum(a.count(i) for i in y):
  print " valid password"


else :
 print "wrong!"

explaintion:

note 1:( a[0].isalpha() ) is equal to your alphabet list and i used it to set code shorter and more readable

note 2:
sum(c.isdigit() for c in a) determine if your password has a number or not you can specify a range for your numbers which should exist in password for ex:
sum(c.isdigit() for c in a) > 2 means if just 2 digit exist in your password , password is vald

1

solved How to debug this Python code? [closed]