Jun 13, 2019 in Python
Q: What is the output of the following?

string = "my name is x"
for i in ' '.join(string.split()):
    print (i, end=", ")

a. m, y, , n, a, m, e, , i, s, , x,
b. my, name, is, x,
c. error
d. m, y, , n, a, m, e, , i, s, , x

1 Answer

0 votes
Nov 11, 2019

Answer is a m, y, , n, a, m, e, , i, s, , x,

Variable i takes the value of one character at a time.

Related questions

0 votes
Jun 13, 2019 in Python
0 votes
Jun 13, 2019 in Python
...