[Python] ZyBook Lab 3.12

Discussão em 'Python' iniciado por Stack, Janeiro 26, 2025.

  1. Stack

    Stack Membro Participativo

    "Write a program that takes a date as input and outputs the date's season. The input is a string to represent the month and an int to represent the day."

    I get a syntax error saying that : needs to be included, but it is. Am I missing a colon somewhere, or is there a separate error?

    File "/home/runner/local/submission/main.py", line 10 else input_month == "June": ^^^^^^^^^^^ SyntaxError: expected ':'

    input_month = input()
    input_day = int(input())

    if input_month == "March" "April" or "June":
    if input_month == "March":
    if 20 <= input_day <= 31:
    print("Spring")
    elif input_month == "April":
    print("Spring")
    else input_month == "June":
    if 1 <= input_day <= 20:
    print("Spring")


    elif input_month == "June" "August" or "September":
    if input_month == "June":
    if 21 <= input_day <= 30:
    print("Summer")
    elif input_month == "August":
    print("Summer")
    else input_month == "September":
    if 1 <= input_day <= 21:
    print("Summer")

    elif input_month == "September" "October" "November" or "December":
    if input_month == "September":
    if 22 <= input_day <= 30:
    print("Autumn")
    elif input_month == "October" or "November":
    print("Autumn")
    else input_month == "December":
    if 1 <= input_day <= 20:
    print("Autumn")

    elif input_month == "December" "January" "February" or "March":
    if input_month == "December":
    if 21 <= input_day <= 31:
    print("Winter")
    elif input_month == "January" or "February":
    print("Winter")
    else input_month == "March":
    if 1 <= input_day <= 19:
    print("Winter")

    else:
    print("Invalid")

    Continue reading...

Compartilhe esta Página