Computer Science, asked by rakeshmca726, 4 months ago

x="1,2,3"
for i in x:
print(i)

Answers

Answered by allysia
0

Correction:

x="1,2,3"

for i in x:

     print(i)

Output:

1

,

2

,

3

Explanation:

The datatype of x is string since you've covered the whole value between quotes.

The program treats 1,2,3 as a combination of letters and not numbers and iterates it as a string.

Consider this for example:

a="apples"

for i in a:

    print i

Here the values being printed would be:

a

p

p

l

e

s

The reason being this whole thing is a string.

Similar questions