Remove spaces at both ends
Remove the spaces before and after a name. A space between two words stays in place. These examples use ordinary spaces.
String.strip
Simple example
Trim the single letter.
Start' a '
Resulta
def main() raises:
print(String(" a ").strip())
a
Advertisements
Everyday examples
Remove the extra spaces copied around a ticket number.
Start' B12 '
ResultB12
def main() raises:
print(String(" B12 ").strip())
B12
Clean up the outside spaces on a shelf label.
Start' Red Apples '
ResultRed Apples
def main() raises:
print(String(" Red Apples ").strip())
Red Apples
Clean up a name copied from a signup sheet.
Start' Ana '
ResultAna
def main() raises:
print(String(" Ana ").strip())
Ana