For your loops (right answer, just a query)


#1

Can someone tell me what this is about? As far as I can see, I had my code correct: the top was my original code, which according to codeacademy, was wrong. The code beneath it DID work, although the only change I made was using double quotes instead of single quotes.

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

# Add your for loop
for char in phrase:
    if char == 'A' or c == 'a':
        print 'X',
    else: 
        print char,

    
#Don't delete this print statement!
print

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,

I'm sure I've used single quotes like this before - was I wrong and are they not interchangeable? Thanks!


#2

In the first version, you have "c == 'a'" when you should have "char == 'a'"


#3

argh... sorry...

its always the silliest things


#4

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