I’ve replaced the A’s but I’m receiving an error about my output, what’s wrong?
Answer
A very common issue here is forgetting to include the comma , at the end of the print statements inside the if and else. Without these, your output will be displayed on a new line! We want the output to all be on the same line.
Remember, Codecademy checks for exactly what it asks for, so if you’re missing a small detail like that, it will be marked wrong until it’s resolved.
Same as with operators like + - * /, these are also operators carried out in some defined order and there is no connection there between 'a' and char, what you wrote does not cause them to be compared
what needs to happen for those to be compared is that == receives them both as arguments
you use == once but expect it to be used twice - doesn’t add up
Similarly, this does not cause 3 and 7 to be added. Why would it?
What is the behaviour of and? What have you been promised that it can do for you?
it says 3 + 5 = 8, and “8 and 7” means that both 8 has to be true and 7 has to be true for the “and” to return true. However, it does not have anything to return to, as there is no “return” or anything like that command. Therefore, it returns 8 and 7, which 8 + 7 = 15. EXPLAINED.
AND is not about addition. It’s about truthiness. When the first operand is truthy, the second operand is returned, though as you say, this is not a program function, so one could prefer to use, yielded. Because there is no short-circuiting the expression defers to the second operand.
phrase = "A bird in the hand..."
# Add your for loop
for char in phrase:
if char == 'A' or char == 'a':
# Don't delete this print statement!
print 'X',
else:
print char,
Hey I just got here, I might be late with the solution but… there is a “print” statement at the bottom of the code that we need there. So we have to have 3 “print” statements. Well Im not sure why but we need it. I hope we get some clarification for that later on.