12. For your A


#1

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

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

else:
    print char

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 hX nd..." instead of "X b i r d i n t h e h X n d . . .".


#2

a comma needs to be placed after char,

and you need an empty print statement outside of your loop,

else:
        print char,




#Here,
print

#3

I actually fixed this issue by:

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

Making sure the else was under the if and not the for...


#4

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.