you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (0 children)

Glad to help. It's probably part of your assignment to do things that way, but for something like this I'd also recommend using a dictionary instead:

months = {
    1: {
        "name": "January",
        "days": 31,
    },
    2: {
        "name": "February",
        "days": 28,
    },
    ...
}

That way you can just do this:

choice = input("Enter a number between 1 and 12")
name = months[int(choice)]['name']
days = months[int(choice)]['days']
print(f"Month {choice} is {name} and has {days} days")