Module 6 Regular Expressions Assignment
Module 6 Regular Expressions Assignment
Regular Expression
1)Write a Python program to check that a string contains only a certain set of characters (in this
case a-z, A-Z and 0-9)
2) Write a Python program to replace all occurrences of space, comma, or dot with a colon.
ANSWERS:
1.
def check_alphanumeric(s):
return s.isalnum()
test_string = "Hello123"
if check_alphanumeric(test_string):
else:
print("The string contains characters outside the range a-z, A-Z, and 0-9.")
2.
def replace_characters(input_string):