Computer Science, asked by skmadarvali2941, 7 months ago

What will be the output of the following code : L=['a','b','c','d'] print "".join(l)

Answers

Answered by mad210203
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