Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Write a program that reads the name of the day and says if it is the weekend (Saturday or Sunday). A student wrote if day == "Saturday" or "Sunday":. Why is it wrong?
Repeat the variable and the comparison on both sides of or.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Correct line. if day == "Saturday" or day == "Sunday":. Each side of or is a full comparison.
Why the other line is wrong. In day == "Saturday" or "Sunday", the part "Sunday" is not a comparison. Python treats a text that is not empty as true, so the whole condition is always true. Every day would be called the weekend.
Check. For Monday the program says It is a school day.
Log in to join the discussion.
Loading…