スクリプトのポイントは、特定の日から 'X' 日後に何曜日になるかを伝えることです。
私は数時間コーディングする方法を学んでいるので、我慢してください.
# Prompt the user for input
print("This scipt is useful in finding out what day of the week it \
will be after 'X' ammount of days in relation to the current date.")
sunday = Sunday = 0
monday = Monday = 1
tuesday = Tuesday = 2
wednesday = Wednesday = 3
thursday = Thursday = 4
friday = Friday = 5
saturday = Saturday = 6
print(" ")
todaysDate = input("Enter todays date: ")
daysFromToday = int(input("Enter a integer for days from today: "))
# Compute equasion
daysFromDate = ((todaysDate + daysFromToday) % 7)
# Display results
print(" ")
print("Today is", todaysDate, "and in", daysFromToday, "days it will be", daysFromDate)
print(" ")
print("Sunday = 0, \
Monday = 1, \
Tuesday = 2, \
Wednesday = 3, \
Thursday = 4, \
Friday = 5, \
Saturday = 6")
input("Press enter to close: ")
私のエラーは
Traceback (most recent call last):
File "C:\Desktop\daysfromdate.py", line 18, in <module>
daysFromDate = ((todaysDate + daysFromToday) % 7)
TypeError: Can't convert 'int' object to str implicitly
を使用して修正しました
todaysDate = eval(input("Enter todays date: "))
これでスクリプトは正常に実行されますが、最後の質問は、変数の単語バージョンで応答させるにはどうすればよいですか?
現在の出力は
Today is 0 and in 100 days it will be 2
そうであってほしい
Today is Sunday in 100 days it will be Tuesday