0

I want to remove the [ ] brackets from list1 variable in python

list1 = ['Order No','Item']

Expected :

>>> print (list1)
'Order No', 'Item'

Actual :

>>> print (list1)
['Order No', 'Item']
petezurich
  • 9,280
  • 9
  • 43
  • 57
Mahesh
  • 29
  • 4

2 Answers2

1

Try the below code:

>>> list1 = ['Order No','Item']
>>> print(str(list1)[1:-1])
'Order No', 'Item'
>>> 

If you don't need the quotes, use:

>>> print(', '.join(list1))
Order No, Item
U13-Forward
  • 69,221
  • 14
  • 89
  • 114
0

Try:

for i in list1:
 print("'" + i + "'")

if you don't want the braces:

for i in list1:
 print(i)
Vipul
  • 734
  • 1
  • 10
  • 27