def strip(strA,isShow=False): #by D@CC #on 2023DApr05 #Project: WioClock #Code: MicroPython #Purpose: strips preceding & trailing blanks #Parm0: str to process #Parm1: isShow=False #returns stripped string #calls: len() # showMP() strC=strA #print(" strC:",strC,":") # before changes if strA=="": return strC lenC=len(strC) "lenC:",lenC if not (strC[0:1]==" "): # if no preceding spaces #no preceding spaces Doh=1 else: # strip blanks from front showMP(isShow,"strC:",strC,0) #mod while strC[0:1]==" ": strB=strC #print("strB:",strB,":") # remove 1 char from front strB=strC[1:] #remove first blank #print("strB:",strB,":") strC=strB #while end #print("done removing preceding blanks") #if end #check for blanks at end #check if any blanks at end if (strC==""): return strC if not (strC[-1]==" "): return strC #strip blanks from rear while strC[-1]==" ": #test if last char blank strB=strC #print("strB:",strB,":") # remove 1 char from rear lenC=len(strC) lenCLess1=len(strC)-1 strB=strC[0:lenCLess1] #remove last blank strC=strB #while end #print("done removing trailing blanks") #print("returning:",strC,":") return strC #def end #/strip.py