-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathString-Operators.py
More file actions
32 lines (29 loc) · 960 Bytes
/
String-Operators.py
File metadata and controls
32 lines (29 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Author: Jessica Strait
# This function takes in a string and evaluates what types of characters are in the string.
# It checks for alphanumeric characters, letters, digits, and identifies upper/lowercase letters.
def identify(s):
# TypeError check
if type(s) != str:
return 'TypeError'
# Establish variables
alnum = False
alpha = False
digits = False
lower = False
upper = False
for character in s:
# A character cannot be a letter of number unless it is also alphanumeric.
if character.isalnum():
alnum = True
if character.isalpha():
alpha = True
if character.isupper():
upper = True
elif character.islower():
lower = True
if character.isdigit():
digits = True
else:
pass
return alnum, alpha, digits, lower, upper
identify(s)