gw1500se Posted June 23, 2019 Share Posted June 23, 2019 It there a way, without a loop, to remove the leading whitespace from each element of an array of strings? TIA. Link to comment Share on other sites More sharing options...
gizmola Posted June 24, 2019 Share Posted June 24, 2019 Like most languages, Python has map(). I'm not sure this is actually better than iterating, given that ltrim is a built in string method: strings = [' hi', ' there', 'friend'] print(strings) strings = list(map(lambda str: str.lstrip(), strings)) print(strings) Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.