shri narayan yadav
shri narayan yadav

Reputation: 29

How to separate a String inside the list into Sub string without create a new list in python

i have python list,

l=['wright_2035566_qwerty , wright_2035566_qwerty,wright_2035566_qwerty']

but i needed this list into that format in python required list

new_list=['wright_2035566_qwerty', 'wright_2035566_qwerty', 'wright_2035566_qwerty']

please help me

Upvotes: 0

Views: 49

Answers (2)

U13-Forward
U13-Forward

Reputation: 71580

Or use:

new_list = list(map(str.strip, l[0].split(',')))

Upvotes: 0

Chayan Bansal
Chayan Bansal

Reputation: 2085

I hope this works for you:

new_list = [x.strip() for x in l[0].split(',')]

Upvotes: 1

Related Questions