What will be the output of the following code : L=['a','b','c','d'] print "".join(l)
Answers
Answered by
2
Output:
abcd
Explanation:
- Join is a in built function in python.
- The join() function is used to join elements of sequence or strings using str separator.
- The join() function takes all the items in a iterable and joins them into single string.
- Syntax: str.join(iterable or list or tuple etc)
Program:
L=['a','b','c','d']
print ("".join(L))
Let us understand the program.
L=['a','b','c','d'] # This is a list of elements with a character.
# Now, join function joins elements of list L by '' sting L.
print ("".join(L)) #This statement is used to print the value of L after joining the characters.
Refer the attached image for the output.
Attachments:
Similar questions
Science,
3 months ago
Math,
3 months ago
India Languages,
7 months ago
Computer Science,
7 months ago
Math,
10 months ago
Math,
10 months ago
Science,
10 months ago