Loops 14-12 For your A


#1

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

Add your for loop

for c in phrase:
if c == "A" or c == "a":
print "X"
else:
print c

Don't delete this print statement!

print

I put my code like above, but it always throws error as:

"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 . . ."."

It looks like I need to get rid of all the space, later I tried phrase.replace(" ",""), but it didn't work.

Can someone kindly help me out? Thanks!


#2

The ,(comma) character after our print statement means that our next
print statement keeps printing on the same line. So if you add the comma, it will solve the problem

if char == "A" or char == "a":
    print "X",
else:
    print char,

#3

Sorry, but no. The codechecker returns the same error even if I write as recommender by Prmishania. i.e.

Oops, try again. Did you replace all of the "A"s and "a"s with "X"s? It looks like you printed "" instead of "X b i r d i n t h e h X n d . . .".
It looks lite the checker does not "see" my code at all, as it says 'you printed ""... however there did was printed: X b i r d i n t h e h X n d . . .None


#4

for char in phrase:
if char == 'A' or char == 'a':
print 'X',
else:
print char,
print ""

Maybe it is a bug.


#5

I thinks the "Error message" mislead us.

instead of"X b i r d i n t h e h X n d . . .", But, there are TWO spaces between words.


#6

This works

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 issue previously was was I had

print 'x'

instead of

print 'X'


#7

You need to add a comma after the
print c,


#9