Class - 12 CBSE Computer Science Important Output Questions 2025
Predict the output of the following code fragments:
x = "apple, pear, peach"
y = x.split(", ")
for z in y :
print(z)
Python
Python Funda
14 Likes
Answer
apple
pear
peach
Working
x.split(", ") breaks up string x into a list of strings so y becomes ['apple', 'pear', 'peach']. The for loop iterates over this list and prints each string one by one.
Answered By
8 Likes