month = int(input())
day = int(input())
if (month == 1 or month == 3 or month == 5 or month == 7 or month == 8 or month == 10) and day == 31:
print(month+1)
print(1)
elif month == 12 and day == 31:
print(1)
print(1)
elif (month == 4 or month == 6 or month == 9 or month == 11) and day == 30:
print(month+1)
print(1)
elif month == 2 and day == 28:
print(month+1)
print(1)
else:
print(month)
print(day+1)
I have this code that just gives the next day of the inputted day (e.g. inputting 3 [March] 4 will give 3 5). However, if I remove the parentheses in the if statements I get wrong answers. If I inputted something like 3 4, it would give the the first day of the next month (4 1). This happens no matter which day I choose. I know this has something to do with the or and and statements. I was wondering if someone could clear up why the output changes when the parentheses are removed.