반응형
달력 만들기
import calendar
def smartphone_calendar():
print("Welcome to the Smartphone Calendar!")
while True:
try:
year = int(input("Enter the year (e.g., 2023): "))
month = int(input("Enter the month (1-12): "))
if 1 <= month <= 12:
cal = calendar.TextCalendar(calendar.SUNDAY)
month_calendar = cal.formatmonth(year, month)
print("\n" + month_calendar)
else:
print("Invalid month. Please enter a value between 1 and 12.")
except ValueError:
print("Invalid input. Please enter valid numeric values for year and month.")
choice = input("Do you want to view another calendar? (y/n): ")
if choice.lower() != 'y':
print("Thank you for using the Smartphone Calendar. Goodbye!")
break
if __name__ == "__main__":
smartphone_calendar()
반응형
'프로그래밍 > Python' 카테고리의 다른 글
[python] 파이썬이 인기 있는 이유 (0) | 2023.08.10 |
---|---|
[Python] PyQt5 5.15.9 (0) | 2023.08.08 |
[python] Numpy - ndarray (0) | 2023.07.15 |
Cannot interpret '<attribute 'dtype' of 'numpy.generic' objects>' as a data type (0) | 2023.07.09 |
[python] matplotlib - pip install matplotlib (0) | 2023.07.09 |