Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.058 X-Spam-Evidence: '*H*': 0.92; '*S*': 0.03; 'subject:Python': 0.06; '21,': 0.07; 'steve': 0.09; 'alias': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '7:35': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hayes': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'print': 0.22; 'cc:2**0': 0.24; 'script': 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'have,': 0.30; 'message-id:@mail.gmail.com': 0.30; 'fri,': 0.33; 'received:google.com': 0.35; 'should': 0.36; 'nov': 0.38; 'pm,': 0.38; 'does': 0.39; 'of:': 0.68; 'age': 0.80; 'age.': 0.84; 'clearer': 0.84; 'safer': 0.84; 'subject:Using': 0.84; 'avoided.': 0.91; 'careful': 0.91; 'to:none': 0.92 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type; bh=MeuArtx5kRpYkieJVIM7OmOUx57GlxVyPSQ43plYxok=; b=zep+n3tHz+yRQGiku8Zy7S7D9JRfhFpUSit+KT3JGEgjK9NGWHk+cd0OzaKgTMVTDU CT6cCW7STW3XEpII7TB5zCwDcrGSjsDnBllYtjno8lzCPNEDTKYswiA6JtQCMMxVdrvp +QO1kqGDlQSogezveVkSzNKEaxwjLwlEbM1GfwN9rUfSdzyevOc3YIKMAepzWS9cLugM gLjY6Td4ujlS/FXNL4o9Bh/m8IkV162htURwmj/hPEgAROMEDvCOIz91bj4W/9/kAy28 c0fQ0TWdZ1Utbf0G8ljk/gbcdmlk3WyWwh+p5cfjPEkIxnb2IK76HnlCiUJcySba7SkD aYtw== MIME-Version: 1.0 X-Received: by 10.50.152.104 with SMTP id ux8mr2420687igb.14.1416559222614; Fri, 21 Nov 2014 00:40:22 -0800 (PST) In-Reply-To: References: Date: Fri, 21 Nov 2014 19:40:22 +1100 Subject: Re: Using Python for date calculations From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 14 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1416559225 news.xs4all.nl 2878 [2001:888:2000:d::a6]:45840 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:81183 On Fri, Nov 21, 2014 at 7:35 PM, Steve Hayes wrote: > This Python script does it for me. > > year = input("Year: ") > age = input("Age: ") > born = year-age > print 'Year of birth:', born One thing to be careful of: The input() function in Python 2 should be avoided. Instead, use int(raw_input("Year: ")) and correspondingly Age. It's much safer and clearer than what you have, which is an alias for eval(raw_input("Year: ")) - very dangerous. ChrisA