Program to accept string ending with alphanumeric character

import re

regex = '[a-zA-z0-9]$'

def check(string):

if(re.search(regex, string)):

print("Accept")

else:

print("Discard")

if __name__ == '__main__' :

string = "python@"

check(string)

string = "python326"

check(string)

string = "python."

check(string)

string = "python"

check(string)


No comments: