Loops.12 : For your A


I only want the A's to turn into x but instead all of them do, why is that?

Replace this line with your code. 

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


you need to do comparison at both sides of the or operator.


can I bracket it or is that the only way?


how do you plan to use parentheses? I don't think that works, but that is because i would never use that approach


Not sure, just wondering if typing c== "A" or c== "a" is the most common method


yea, that is quit common. there are of course other options, for example:

if c in ('a','A'):

but what you currently have is fine :slight_smile:


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