sirimiri
sirimiri

Reputation: 539

Convert list input to string out

I have a list as below, may I know how do I convert to strings output?

Input
A = [['I', 'love', 'apple','.'], 
     ['Today', 'is', 'Sunday', '.'], 
     ['How', 'are', 'you'],
     ['What', 'are', 'you','doing']]

Output
I love apple.
Today is Sunday.
How are you
What are you doing

Upvotes: 1

Views: 119

Answers (2)

user17372295
user17372295

Reputation:

Please use:

for row in X:
    print(' '.join(X))

Upvotes: 0

Jacob Lee
Jacob Lee

Reputation: 4680

You can simply use a for loop to iterate through each list nested in the list A.

A = [
    ['I', 'love', 'apple.'],
    ['Today', 'is', 'Sunday.'],
    ['How', 'are', 'you'],
    ['What', 'are', 'you', 'doing']
]

for row in A:
    print(' '.join(row))

Upvotes: 2

Related Questions