12. For your A


#1

https://www.codecademy.com/courses/python-beginner-en-cxMGf/1/4?curriculum_id=4f89dab3d788890003000096#

My code keeps returning the error "Oops, try again. Did you replace all of the "A"s and "a"s with "X"s? It looks like you printed "X bird in the hXnd..." instead of "X b i r d i n t h e h X n d . . ."."

I have tried to find similar posts to see if anyone else has had the same issue but have had no luck. I feel like my code is doing everything it is supposed to other than the spaces it wants in between the characters being printed out. I have also tried to add an additional print line to fix this but that does not seem to solve it either. Any suggestions would be greatly appreciated!

Thanks

Here is 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

#2

from the information section of the exercise:

The , character after our print statement means that our next print statement keeps printing on the same line

from the instructions;

If char is an 'A' or char is an 'a', print 'X', instead of char. Make sure to include the trailing comma.

Otherwise (else:), please print char, with the trailing comma

i don't see the trailing comma's? Don't use parentheses, this is python2, print is still a statement. using parentheses + comma's causes tuples (immutable lists), something we don't want


#3

Thanks for the reply and I realized that was another piece of info I should have included in my original post because if I include the comma after: print("X") or print "X", this is the output I get...

X
b
i
r
d

i
n

t
h
e

h
X n
d
.
.
.


#4

With the same error.


#5

both print "X", and print char, should have a trailing comma, do you have this? Please show your full code


#6

I did not. I failed to realize that I needed the comma after the print(char) as well as the print("X"). That seems obvious now, thank you!


#7