omz:forum

    • Register
    • Login
    • Search
    • Recent
    • Popular

    Welcome!

    This is the community forum for my apps Pythonista and Editorial.

    For individual support questions, you can also send an email. If you have a very short question or just want to say hello — I'm @olemoritz on Twitter.


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

    Pythonista
    2
    3
    1519
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Pythonistapro777
      Pythonistapro777 last edited by

      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:
      <code><pre>
      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())
      </code></pre>

      1 Reply Last reply Reply Quote 0
      • ccc
        ccc last edited by ccc

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

        1 Reply Last reply Reply Quote 0
        • Pythonistapro777
          Pythonistapro777 last edited by

          You're a legend!

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Powered by NodeBB Forums | Contributors