C is not Defined


#1

Continuing the discussion from 12/19 For your A:



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


I'm getting a "c is not defined" error code.

Shouldn't c be implicitly defined????


>>> phrase = "A bird in the hand..."
>>> if c == "A" or c == "a":
...     print "X"
... else:
...     print c,
... 
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'c' is not defined


#2

Can I see all your code.


#3

If this is all your code you need a for loop. after the phrase and before the if


#4

Yeah. That's all of my code. Thanks for the advice.


#5

Tried that, and it's honestly not making much sense that way.


#6

My new result:

'''

phrase = "A bird in the hand..."
for c in phrase:
... if c == "A" or c == 'a':
... print "X"
... else:
... print c,
...
X
b i r d i n t h e h X
n d . . .

'''


#7

Phew. Got it figured out!

'''

phrase = "A bird in the hand..."
for c in phrase:
... if c == "A" or c == "a":
... print "X",
... else:
... print c,
...
X b i r d i n t h e h X n d . . .

'''