Python - First and last character in string must be alpha numeric, else delete
Question: I am wondering how I can implement a string check, where I want to make sure
that the first (&last) character of the string is alphanumeric. I am aware of
the `isalnum`, but how do I use this to implement this check/substitution?

So, I have a string like so:

    
    
    st="-jkkujkl-ghjkjhkj*"
    

and I would want back:

    
    
    st="jkkujkl-ghjkjhkj"
    

Thanks..


Answer: Though not exactly what you want, but using str.strip should serve your
purpose

    
    
    import string
    
    st.strip(string.punctuation)
    Out[174]: 'jkkujkl-ghjkjhkj'
    

