3
現在、「インポート」に独立して機能する「オリジナルプログラム」から自分のコードをインポートしようとしています。 「日付が定義されていません」というエラーが表示されます。私はエラーがグローバル変数と関係していると仮定します。私はこれを知っていて、問題を自分自身で解決しようとしていました。すべてのヘルプ感謝:)インポートされた変数が定義されていません
**Original Program**
def validDate(date, month, day):
months = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
days = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
leapyear = ((date % 4) == 0) and ((date % 100) != 0) or ((date % 4) ==
0) and ((date % 100) == 0) and ((date % 4000) == 0)
if leapyear:
days[1] += 1
valid = (day <= days[months.index(month)] and day > 0 and (1753 <=
date))
print(valid)
date = int(input("Enter year: "))
month = int(input("Enter month: "))
day = int(input("Enter day: "))
validDate(date, month, day)
**Import**
from libHWDate import validDate
validDate(date, month, day)