Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!rt.uk.eu.org!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'else:': 0.03; 'from:addr:yahoo.co.uk': 0.04; 'correct.': 0.07; 'subject:Error': 0.07; 'arc': 0.09; 'lawrence': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'rewrite': 0.09; 'python': 0.11; 'integer.': 0.16; 'length.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'red,': 0.16; 'wrote:': 0.18; 'variable': 0.18; 'value.': 0.19; 'entered': 0.20; 'written': 0.21; 'help.': 0.21; 'example': 0.22; 'header:User-Agent:1': 0.23; 'error': 0.23; 'integer': 0.24; "i've": 0.25; 'header:X -Complaints-To:1': 0.27; 'header:In-Reply-To:1': 0.27; 'testing': 0.29; "i'm": 0.30; 'code': 0.31; 'getting': 0.31; 'values.': 0.31; 'url:python': 0.33; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'thanks': 0.36; 'url:org': 0.36; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'most': 0.60; 'free': 0.61; 'url:3': 0.61; 'further': 0.61; 'here': 0.66; 'circle': 0.68; 'press': 0.70; 'goal': 0.75; 'bite': 0.84; 'subject:Testing': 0.84; 'scott': 0.93 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Mark Lawrence Subject: Re: Error Testing Date: Sat, 19 Oct 2013 13:37:01 +0100 References: <33549834-2f27-47f3-abea-eb3486909dec@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: host-78-147-19-253.as13285.net User-Agent: Mozilla/5.0 (Windows NT 6.1; rv:24.0) Gecko/20100101 Thunderbird/24.0.1 In-Reply-To: <33549834-2f27-47f3-abea-eb3486909dec@googlegroups.com> 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: 40 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1382186251 news.xs4all.nl 15940 [2001:888:2000:d::a6]:33548 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:57093 On 19/10/2013 13:23, Scott Novinger wrote: > Hello. > > I've written a program for my kids to calculate arc length. I want to include some error testing for value types entered that are something other than integer values. > > My goal is to make sure that the value entered for the radius is an integer value. > > How could I rewrite this code to make sure I accomplish my goal of getting an integer value entered? I know the construct is not correct. I'm just learning how to program. > > # Create the variable for radius, "radius". > print('Please enter the circle radius and press ENTER:') > radius = input() > > # Check to make sure the entered value is an integer. > if type(radius) != type(int): > print('You must enter an integer value.') > print('Please enter the circle radius and press ENTER:') > radius = input() > else: > print('The radius you entered is: ' + radius) > > radius = int(radius) > > Thanks for your help. I'm using Python v3.2 for windows. > > Scott > Please see the example here http://docs.python.org/3/tutorial/errors.html#handling-exceptions. If you want further data feel free to ask, we don't bite :) -- Roses are red, Violets are blue, Most poems rhyme, But this one doesn't. Mark Lawrence