954,515 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

First element within nested list

Im trying to find the first element in each nested list:
x = [['hey','wassup'],['are','you','ok'],['i','am','fine']

So that I get print a string: "hw ayo iaf"

so far I have:

def first_letters():
x = [['hey','wassup'],['are','you','ok'],['i','am','fine']

Thanks!

effBlam
Newbie Poster
13 posts since Oct 2011
Reputation Points: 10
Solved Threads: 0
 
print(' '.join(''.join(z[0] for z in y) for y in x))
Gribouillis
Posting Maven
Moderator
2,786 posts since Jul 2008
Reputation Points: 1,044
Solved Threads: 691
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: