allexj allexj - 1 year ago 74
Python Question

Delete spaces from items in a list

I have this list:

input_list = ["", "", ""]

And I'd like to remove that space in the second e third words... How can I do?

I tried with:

for x in input_list:
x.strip(" ")

and with:

for x in input_list:
x.replace(" ","")

Answer Source
your_list = [element.strip() for element in your_list]
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download