-4
list = [(u'SFG2',), (u'FG2',), (u'FG3',), (u'SFG1',), (u'RM1',), (u'RM2',), (u'RM3',), (u'FG1',)]  

expected output:

u'SFG2'    
u'FG2'  
u'FG3'
Cœur
  • 37,241
  • 25
  • 195
  • 267
  • Possible duplicate of [How to use one print() in python to print list items line by line - not in one streak?](https://stackoverflow.com/questions/24992431/how-to-use-one-print-in-python-to-print-list-items-line-by-line-not-in-one-s) – gold_cy Mar 14 '18 at 10:33
  • list is builtin keyword. please don't use it. – Rahul Mar 14 '18 at 10:37

2 Answers2

1

Iterate over your list and use index.

ex:

my_list = [(u'SFG2',), (u'FG2',), (u'FG3',), (u'SFG1',), (u'RM1',), (u'RM2',), (u'RM3',), (u'FG1',)] 
for i in my_list:
    print i[0]

Output:

SFG2
FG2
FG3
SFG1
RM1
RM2
RM3
FG1
Sean Breckenridge
  • 1,932
  • 16
  • 26
Rakesh
  • 81,458
  • 17
  • 76
  • 113
  • list is builtin. Please don't use at least while answering. This promotes negative practices. Thanks. – Rahul Mar 14 '18 at 10:36
0
In [1]: list1 = [(u'SFG2',), (u'FG2',), (u'FG3',), (u'SFG1',), (u'RM1',), (u'RM2',), (u'RM3',), (u'FG1',)]

In [2]: list2 = [x for tup in list1 for x in tup]

In [3]: list2
Out[3]: ['SFG2', 'FG2', 'FG3', 'SFG1', 'RM1', 'RM2', 'RM3', 'FG1']

NB: I am using python 3.x and you should too!

Rahul
  • 10,830
  • 4
  • 53
  • 88
  • Why should they use 3.6.2? – Ashwini Chaudhary Mar 14 '18 at 11:06
  • I meant 3.x over 2.7 – Rahul Mar 14 '18 at 11:08
  • There's usually a reason behind using 2.7, for example the whole VFX and animation industry is still using 2.7 sadly. [2.7 has still some time left](https://mail.python.org/pipermail/python-dev/2018-March/152348.html) :) . Secondly, there's nothing special in this solution that can't be done in 2.7, hence your statement doesn't really fit. – Ashwini Chaudhary Mar 14 '18 at 11:20
  • Noted. Just wanted to make it clear that The output I provided is in python 3. – Rahul Mar 14 '18 at 11:23