CBSE Class 12 Computer Science Question 42 of 57

Review of Python Basics — Question 42

Back to all questions
42
Question

Question 37

Write a Python program to convert a string to a list.

Solution
string = input("Enter the string: ")
char_list = list(string)

print("String converted to list:", char_list)
Output
String converted to list: ['P', 'y', 't', 'h', 'o', 'n']
Answer

string
=
input
(
"Enter the string: "
)
char_list
=
list
(
string
)
print
(
"String converted to list:"
,
char_list
)
Output
String converted to list: ['P', 'y', 't', 'h', 'o', 'n']