KnowledgeBoat Logo
|

Informatics Practices

Select the output of the following expression:

str1 = "pen"
print(list(str1))
  1. ['p', 'e', 'n' ]
  2. [pen]
  3. [p/e/n]
  4. { "pen" }

Python List Manipulation

1 Like

Answer

['p', 'e', 'n']

Reason — The list() function in Python can be used to convert a string into a list of its individual characters. Therefore, when we execute list(str1) where str1 = "pen", it will convert the string "pen" into a list containing its characters: ['p', 'e', 'n'].

Answered By

1 Like


Related Questions