I have a list of strings that I want to apply a method (.split). I know this can be done by a for loop but knowing the mentality of python I assume there is a better way, like the map function
Below is the thing I want written using for loop
config = ['a b', 'c d']
configSplit = [None] * len(config)
for x in range(len(config)):
configSplit[x] = config[x].split()
configSplit
> [['a', 'b'], ['c', 'd']]
Aucun commentaire:
Enregistrer un commentaire