Python Forum

Full Version: Python symbols AND letters
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
symbols = "~`!@#$%^&*()/_-+={}[]:>;',</?*-+"


contains_symbol = False
for symbols in symbols:
    if symbols in pw1:
      contains_symbol = True
      Score+=5
      break
        print("Your password has both symbols and letters")
This code works but it breaks if you only do symbols, it should only be True when both letters and symbols are prestent.

Moderator Larz60+: Added Python tags. Please do this in the future (see help, BBCODE)
You need to combine the check for symbols with the check for letters. You can check for letters very easily: pw1.isalpha(). Then combine with and and you're good.

And please use python tags around your code.