Loops.12 : For your A


#1



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",
    else:
        print c,


#2

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


#3

can I bracket it or is that the only way?


#4

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


#5

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


#6

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:


#7

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