importre# Pat to check if first letter is capital
pat=re.compile("[A-Z].*")defpseudo_alphabet(s):# Replace all non alphabets and spaces from sentence
ss=re.sub("[^a-zA-Z0-9 ]+","",s)# Split by space
l=ss.split()# Separate lists for upper and lower case words
uw,lw=[],[]forwinl:# If word matches first letter upper-case, add to "uw" else to "lw"
ifpat.match(w):uw.append(w)else:lw.append(w)return' '.join(sorted(lw))+' '+' '.join(sorted(uw,reverse=True))print(pseudo_alphabet(s))
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Python