輸入數字算出月份
months = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'] monthdays=[31,28,31,30,31,30,31,31,30,31,30,31] def answer(): day = int(input("Please enter the day of 2010 (1~365):")) current=0 i=0 while current<day: current = current + monthdays[i] i=i+1 print months[i-1] #game start. Again='y' while Again=='y': answer()
如有錯誤 歡迎指正