There is something wrong with the nested if statements in the code block, they are what is causing the code to not execute. I don’t know why this is happening. I’m a newbie at this so please keep that in mind when answering the question, we haven’t really studied too further in coding yet.
The code doesn’t run:
<code>year = int(input("Enter the year: "))
day = input("Enter the day: ")
jan = 31
mar = 31
april = 30
may = 31
june = 30
july = 31
august = 31
september = 30
october = 31
november = 30
if year % 4:
feb = 29
if day == 1:
weekday = "Monday"
elif day == 2:
weekday = "Tuesday"
elif day == 3:
weekday = "Wednesday"
elif day == 4:
weekday = "Thursday"
elif day == 5:
weekday = "Friday"
elif day == 6:
weekday = "Saturday"
elif day == 7:
weekday = "Sunday"
print("January 1, ", year, " is ", weekday)
count = 0
i = 0
while count <= jan:
for i in range (0, 7):
count += 1
print(i)
</code>
<code>year = int(input("Enter the year: "))
day = input("Enter the day: ")
jan = 31
mar = 31
april = 30
may = 31
june = 30
july = 31
august = 31
september = 30
october = 31
november = 30
if year % 4:
feb = 29
if day == 1:
weekday = "Monday"
elif day == 2:
weekday = "Tuesday"
elif day == 3:
weekday = "Wednesday"
elif day == 4:
weekday = "Thursday"
elif day == 5:
weekday = "Friday"
elif day == 6:
weekday = "Saturday"
elif day == 7:
weekday = "Sunday"
print("January 1, ", year, " is ", weekday)
count = 0
i = 0
while count <= jan:
for i in range (0, 7):
count += 1
print(i)
</code>
year = int(input("Enter the year: "))
day = input("Enter the day: ")
jan = 31
mar = 31
april = 30
may = 31
june = 30
july = 31
august = 31
september = 30
october = 31
november = 30
if year % 4:
feb = 29
if day == 1:
weekday = "Monday"
elif day == 2:
weekday = "Tuesday"
elif day == 3:
weekday = "Wednesday"
elif day == 4:
weekday = "Thursday"
elif day == 5:
weekday = "Friday"
elif day == 6:
weekday = "Saturday"
elif day == 7:
weekday = "Sunday"
print("January 1, ", year, " is ", weekday)
count = 0
i = 0
while count <= jan:
for i in range (0, 7):
count += 1
print(i)
The code was supposed to run.
New contributor
Hassan Shehzad is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.