Why my output is way off even if my code is right?


my code :-

phrase = "A bird in the hand..."

# Add your for loop
for char in phrase:
  if char == "A" or char == "a":
    print "X",
    print char ,
#Don't delete this print statement!

my output :-

 X  ib  dr  i    n  ht   e  Xh  dn  .. .

Also unable reproduce this problem.

Just for the heck of it, what happens if we iterate a list, instead of a string?

for char in list(phrase):

thanks, i got it . :slight_smile:

1 Like