a = [apple,[green,red,yellow]]
print(a[0]+ " available in these colours " + a[1[]])
how do I concatenate string with list in list items ?
expected result :-
apple available in these collars green red yellow
a = [apple,[green,red,yellow]]
print(a[0]+ " available in these colours " + a[1[]])
how do I concatenate string with list in list items ?
expected result :-
apple available in these collars green red yellow
Assuming you start with
a = ['apple',['green', 'red', 'yellow']]
Then a[0]
is a string, and a[1]
is a list of strings. You can change a[1]
into a string using ', '.join(a[1])
, which will concatenate them using a comma and a space.
So
a[0] + ' available in ' + ', '.join(a[1])
should work, as you can concatenate strings with +
.