If else error [SOLVED] | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

If else error [SOLVED]

I am a new member, and have given myself the challenge of creating a program that tells you the date and month of an inputed number. Can somebody please explain why this program always prints “st of January” when it shouldn’t? Also, should I be using a different or more efficient loop/conditional? https://code.sololearn.com/cF0ACiIXAs7R/?ref=app

3rd Sep 2019, 9:30 AM
OverreactingCat
OverreactingCat - avatar
1 Answer
+ 3
Make sure your conditions include the variable a==1||a==21||a==31 ect. Make sure you use == instead of = as a single equals is an assessment operator, double equals == compares. with a = 1 this means store 1 inside of variable a.. this is not what you want. a==1 means does the value of a equal 1? yes it does so this returns true👍
3rd Sep 2019, 9:38 AM
D_Stark
D_Stark - avatar