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

https://www.codecademy.com/courses/learn-python/lessons/python-2-loops/exercises/for-your-a?action=resume_content_item

my code :-

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

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

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