I know that this has been asked before, but I cant for the life of me understand it. I'm trying to create a simple program that gets two dates, and counts shows how many days are left between them.
This is my current code:
month = 0
day = 0
year = 0
def getDate(): #gets the current date
global month
global day
global year
print( 'What is the current month?' )
month = month + int(input())
print( 'What is the current day?' )
day = day + int(input())
print( 'What is the current year?' )
year = year + int(input())
print( 'The current date is ' + str(month) + '/' + str(day) + '/' + str(year) + '. Is this correct?' )
YESNO = input() #confirms date
if YESNO == 'YES' or YESNO == 'yes':
print( 'Okay.' )
else:
getDate()
newMonth = 0
newDay = 0
newYear = 0
def newDate(): #gets the desired countdown date
global newMonth
global newDay
global newYear
print( 'What is the desired countdown month?' )
newMonth = newMonth + int(input())
print( 'What is the desired countdown day?' )
newDay = newDay + int(input())
print( 'What is the desired countdown year?' )
newYear = newYear + int(input())
print( 'The desired countdown date is ' + str(newMonth) + '/' + str(newDay) + '/' + str(newYear) + '. Is this correct?' )
YESNO = input() #confirms date
if YESNO == 'YES' or YESNO == 'yes':
print( 'Okay.' )
else:
newDate()
def COUNTDOWN(): #prints countdown
global newMonth
global newDay
global newYear
global month
global day
global year
if newMonth < Month:
countDownMonth = int(Month) - int(newMonth)
else:
countDownMonth = int(newMonth) - int(Month)
if newDay < Day:
countDownDay = int(Day) - int(newDay)
else:
countDownDay = int(newDay) - int(Day)
if newMonth < Year:
countDownYear = int(Year) - int(newYear)
else:
countDownYear = int(newYear) - int(Year)
print( countDownMonth + '/' + countDownDay + '/' + countDownYear )
getDate()
newDate()
COUNTDOWN()
EDIT:
I apologize, I didn't realize it wasn't indented.
EDIT:
My question is how do I create a cross-function variable?