If have string stored as list under name
>>> name
['Aaron']
Using str(name) i get
>>> str(name)
"['Aaron']"
Output Required is
'Aaron'
Not
"['Aaron']"
Because my regular expression is not recognizing it as a string.
If have string stored as list under name
>>> name
['Aaron']
Using str(name) i get
>>> str(name)
"['Aaron']"
Output Required is
'Aaron'
Not
"['Aaron']"
Because my regular expression is not recognizing it as a string.
To join list of multiple elements (strings) in the list, you may use str.join
as
>>> name = ['Aaron', 'Sheron']
# v to join the words in the list using space ' '
>>> ' '.join(name)
'Aaron Sheron'
However, you are having a list of just one element. In order to access the element at 0
th index, you need to pass index as (PS: str.join
will work here too, but it is not required):
>>> name = ['Aaron']
# v fetch `0`th element in the list
>>> name[0]
'Aaron'
Please also refer:
You can also use:
''.join(name)
join
joins all elements of the list into one string.