Reputation: 151
letters1 = "abcdefghijklmnopqrstuvwxyz"
letters2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
def is_valid(strs):
char_b = True
for char in range(0, len(strs)):
if strs[char] not in (letters1 or letters2):
char_b == False
return char_b
I don't understand why this won't work, anyone mind giving me a hint? It just always returns true.
Upvotes: 0
Views: 55
Reputation: 1121614
You need to set char_b
, not test for equality. Replace:
char_b == False
with
char_b = False
Your test is incorrect:
if strs[char] not in letters1 + letters2:
or simplify your function to:
def is_valid(strs):
return strs.isalpha()
Upvotes: 2