I am facing a problem with all my list items. The list shows like:
[('abc',), ('def',), ...]
I want the list to be like this:
['abc', 'def', ...]
How do I fix this?
I am facing a problem with all my list items. The list shows like:
[('abc',), ('def',), ...]
I want the list to be like this:
['abc', 'def', ...]
How do I fix this?
Your list contains tuples of strings, not directly strings. They are not unnecessary characters, they indicate that you have tuples.
You could unpack every 1-uple in your list using list comprehension:
myList = [('abc',), ('def',)]
myNewList = [a[0] for a in myList] #['abc','def']
these are list of tuples you have iterate twice
list_ = [('abc',),('def',)]
for i in list_:
for j in i:
print(j)
out put will be in single elements then you can make a new list and append these elements.