Why does "---".join(list) only recognize as a space?


#1

Why aren’t my hyphens recognized?

list1 = ['a b c d'],['a a a a']

for v in list1:
    print "----".join(v) 

Outputs:

a b c d
a a a a

===========================

Solution:

list1 = ['a', 'b', 'c', 'd'],['a a a a']

for v in list1:
    print "----".join(v) 

Outputs:

a----b----c----d
a a a a

#2

both lists only have a single value. 'a b c d' is a single string, so there nothing to join together


#3

Ahhhh okay thanks. So I just need to make the list [‘a’,‘b’,‘c’,‘d’]


#4

yes, now join has different strings (elements in list) to join together


#5

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.