Python Forum
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Python symbols AND letters
#1
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)
Reply
#2
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.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Python script that deletes symbols in plain text nzcan 3 642 Sep-05-2023, 04:03 PM
Last Post: deanhystad
  eliminating letters when typed in python window deebo 0 1,706 Jan-05-2021, 09:26 AM
Last Post: deebo
  cyrillic symbols in tables in reportlab. hiroz 5 11,209 Sep-10-2020, 04:57 AM
Last Post: bradmalcom
  Unexpected output: symbols for derivative not being displayed saucerdesigner 0 2,012 Jun-22-2020, 10:06 PM
Last Post: saucerdesigner
  Python Hangman Game - Multiple Letters Problem t0rn 4 4,538 Jun-05-2020, 11:27 AM
Last Post: t0rn
  Replacing symbols by " Tiihu 1 1,813 Feb-13-2020, 09:27 PM
Last Post: Larz60+
  How do I delete symbols in a list of strings? Than999 1 2,242 Nov-16-2019, 09:37 PM
Last Post: ibreeden
  Python Hangman Replacing "_" with letters. 2skywalkers 6 11,984 Jun-25-2018, 12:01 PM
Last Post: gruntfutuk
  Strings containing both symbols and letters gullidog 13 8,136 Apr-05-2017, 12:27 PM
Last Post: ankit
  Symbols Distinguished From Letters? MeMeBigBoy 3 3,829 Apr-05-2017, 12:21 PM
Last Post: wavic

Forum Jump:

User Panel Messages

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