0
Username = input("please enter a username: ")
Password = input("please enter a password: ")

if "A" or "B" or "C" or "D" or "E" or "F" or "G" or "H" or "I" or "J" or "K" or "L" or "M" or "O" or "P" or "Q" or "S" or "T" or "U" or "V" or "W" or "X" or "Y" or "Z" in Password:
    print("yes")
Jim Hewitt
  • 1,726
  • 4
  • 24
  • 26
Ben Gayne
  • 13
  • 1
  • 2
    You might want to take a look at [this](http://stackoverflow.com/q/20002503/198633) – inspectorG4dget Jul 21 '16 at 21:12
  • Please add description to your code. – Ankit Tanna Jul 21 '16 at 21:20
  • `or` doesn't work that way; your expression is effectively `"A" or ("B" or ("C" ... or ("Z" in Password)))` Python will go "`"A"` evaluates to True, so the first `or` is True, no need to check the rest!", and thus your expression will always evaluate to True. For your code to work you'd need `if "A" in Password or "B" in Password or ...` (which is a bad approach, obviously - the answers give good approaches). – marcelm Jul 21 '16 at 22:23

2 Answers2

3

Try this:

if Password != Password.lower() print("yes")

jktin12
  • 429
  • 2
  • 7
1

str.isupper() tells you whether a string is uppercased. You can use this to test whether each individual character is uppercased. Loop that over the entire password string and you have the functionality of checking if any character is uppercased

In [3]: p = input("Please enter a password: ")
Please enter a password: asfF

In [4]: any(char.isupper() for char in p)
Out[4]: True

In [5]: p = input("Please enter a password: ")
Please enter a password: asdf

In [6]: any(char.isupper() for char in p)
Out[6]: False
inspectorG4dget
  • 110,290
  • 27
  • 149
  • 241