Python-programming-exercises
Python-programming-exercises copied to clipboard
Exercise 1
can only join iterable
can only join iterable
It means that you can use join operation only on something that can be iterated through such as a list or a tuple.
list1 = ['a','b','c']
print(",".join(list1))
This will result in the output:
>>> a,b,c
can only join iterable
Any iterable like a list or a tuple having elements of data type (class) string can be joined to form a new sting.
You may either convert those elements to string if needed or do the following
print(*list1, sep=',')