Categories

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

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.

Click here to read more about Python
Click here to read more about Insurance

Related questions

Madanswer
Jun 13, 2019 in Python
Jun 13, 2019 in Python
Jun 13, 2019 in Python
...