Forum Archive

[SOLVED!] Help with console error (short code)

Pythonistapro777

New project. It ask for the date of an event and counts the days till that event!

Please help with the error.

Thanks in advance!

Here's the code:


import datetime
import console
from scene import *
class question (Scene):
def setup(self):
self.show_instructions = True
self.particles = set()
self.p_size = 64 if self.size.w > 700 else 32
def draw(self):
background(0, 0, 0)
if self.show_instructions:
s = 40 if self.size.w > 700 else 17
event = console.input_alert('Event', 'Please enter the event name.\ni.e. First day of school', '', 'Enter')
today = datetime.date.today()
find = console.input_alert('Date', 'Please enter the date you would like to countdown to.\ni.e. 2009 (year),6 (month),29 (day)', '', 'Enter')
try:
year, month, day = [int(s.strip()) for s in find.split(',')]
someday = datetime.date(year, month, day)
diff = someday - today
print(diff.days)
except ValueError:
print 'Incorrect date format (must be "year, month, day")'
run(question())

ccc

https://github.com/cclauss/Pythonista_scene/blob/master/days_until_event.py

Pythonistapro777

You're a legend!