Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #43197
| Path | csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <thomasancilleri@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.003 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; 'syntax': 0.04; 'elif': 0.05; '#if': 0.07; 'continuation': 0.07; 'subject:help': 0.08; 'converts': 0.09; 'restart': 0.09; 'to:addr:comp.lang.python': 0.09; 'cc:addr:python-list': 0.11; 'python': 0.11; '"to': 0.16; 'looping': 0.16; 'notably': 0.16; 'prevent': 0.16; 'skip:= 10': 0.16; 'typing': 0.19; 'meant': 0.20; 'starts': 0.20; 'coding': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'header:User- Agent:1': 0.23; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'this:': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'fixed': 0.29; "i'm": 0.30; '(which': 0.31; 'code': 0.31; 'submitting': 0.31; 'another': 0.32; 'quite': 0.32; 'skip:# 10': 0.33; "i'd": 0.34; 'received:209.85': 0.35; 'problem.': 0.35; 'received:209.85.220': 0.35; 'convert': 0.35; 'received:google.com': 0.35; 'version': 0.36; 'next': 0.36; 'thanks': 0.36; 'unit': 0.37; 'received:209': 0.37; 'starting': 0.37; 'sure': 0.39; 'most': 0.60; 'from:no real name:2**0': 0.61; 'conversion': 0.61; 'simply': 0.61; 'first': 0.61; 'here': 0.66; 'reply': 0.66; 'invalid': 0.68; 'condition.': 0.84; 'meters': 0.84; 'inches': 0.91 |
| X-Received | by 10.49.2.170 with SMTP id 10mr1862356qev.40.1365522427049; Tue, 09 Apr 2013 08:47:07 -0700 (PDT) |
| Newsgroups | comp.lang.python |
| Date | Tue, 9 Apr 2013 08:47:05 -0700 (PDT) |
| In-Reply-To | <mailman.348.1365516328.3114.python-list@python.org> |
| Complaints-To | groups-abuse@google.com |
| Injection-Info | glegroupsg2000goo.googlegroups.com; posting-host=68.194.186.13; posting-account=iVEBawoAAADC2zcRyETBjispujvlKyYR |
| References | <b93147e7-9d17-4232-99a3-767b88f9e9ba@googlegroups.com> <596ca4b8-b5aa-4112-b086-6320108075f7@googlegroups.com> <mailman.348.1365516328.3114.python-list@python.org> |
| User-Agent | G2/1.0 |
| X-Google-Web-Client | true |
| X-Google-IP | 68.194.186.13 |
| MIME-Version | 1.0 |
| Subject | Re: While loop help |
| From | thomasancilleri@gmail.com |
| To | comp.lang.python@googlegroups.com |
| Content-Type | text/plain; charset=ISO-8859-1 |
| Content-Transfer-Encoding | quoted-printable |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Message-ID | <mailman.364.1365524732.3114.python-list@python.org> (permalink) |
| Lines | 54 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1365524732 news.xs4all.nl 2704 [2001:888:2000:d::a6]:54519 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:43197 |
Show key headers only | View raw
Sorry I'm just starting to learn python and I'm not sure what version I'm using to be quite honest. I just started typing it up in Komodo edit (Which I'm not personally a fan in particular) I fixed the missing parenthesis which fixed the invalid syntax problem. Also, I apologize for submitting code that did not run. This is the code I have now before I tried looping it again:
#!/usr/bin/env python
#Program starts here
print "To start the Unit Converter please type the number next to the conversion you would like to perform"
choice = raw_input("\n1:Inches to Meter\n2:Millileters to Pint\n3:Acres to Square-Miles\n")
#If user enters 1:Program converts inches to meters
if choice == 1:
#operation = "Inches to Meters"
number = int(raw_input("\n\nType the amount in Inches you would like to convert to Meters.\n"))
calc = round(number * .0254, 2)
print "\n",number,"Inches =",calc,"Meters"
restart = raw_input("If you would like to perform another conversion type: true\n")
#If user enters 2:Program converts millimeters to pints
elif choice == 2:
#operation = "Milliliters to Pints"
number = int(raw_input("\n\nType the amount in Milliliters you would like to convert to Pints.\n"))
calc = round(number * 0.0021134,2)
print "\n",number,"Milliliters =",calc,"Pints"
restart = raw_input("If you would like to perform another conversion type: true\n")
#If user enter 3:Program converts kilometers to miles
elif choice == 3:
#operation = "Kilometers to Miles"
number = int(raw_input("\n\nType the amount in Kilometers you would like to convert to Miles.\n"))
calc = round(number * 0.62137,2)
print "\n",number,"Kilometers =",calc,"Miles"
restart = raw_input("If you would like to perform another conversion type: true\n")
Not sure what you meant to exactly by this:
"There's a lot of duplicated code here, most notably your continuation
condition. You can simply back-tab after the elif block and have some
code that reunites all the branches; this would also make things
clearer"
Thanks for your reply and if you have any ideas for me to improve my coding that will prevent me from learning python in a sloppy way. I'd like to learn it correctly the first time!
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
While loop help thomasancilleri@gmail.com - 2013-04-09 06:32 -0700
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 06:57 -0700
Re: While loop help Dave Angel <davea@davea.name> - 2013-04-09 13:12 -0400
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 10:18 -0700
Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 03:23 +1000
Re: While loop help Dave Angel <davea@davea.name> - 2013-04-09 13:30 -0400
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 06:58 -0700
Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 00:05 +1000
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 08:47 -0700
Re: While loop help Joel Goldstick <joel.goldstick@gmail.com> - 2013-04-09 12:02 -0400
Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 02:10 +1000
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:24 -0700
Re: While loop help Joel Goldstick <joel.goldstick@gmail.com> - 2013-04-09 12:36 -0400
Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 02:47 +1000
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:57 -0700
Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 03:08 +1000
Re: While loop help Dave Angel <davea@davea.name> - 2013-04-09 13:27 -0400
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:57 -0700
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:24 -0700
Re: While loop help Walter Hurry <walterhurry@lavabit.com> - 2013-04-09 19:35 +0000
Re: While loop help Dave Angel <davea@davea.name> - 2013-04-09 16:12 -0400
Re: While loop help Walter Hurry <walterhurry@lavabit.com> - 2013-04-09 20:59 +0000
Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 08:36 +1000
Re: While loop help rusi <rustompmody@gmail.com> - 2013-04-10 08:59 -0700
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 08:47 -0700
Re: While loop help Chris Angelico <rosuav@gmail.com> - 2013-04-10 00:00 +1000
Re: While loop help thomasancilleri@gmail.com - 2013-04-09 09:49 -0700
Re: While loop help Larry Hudson <orgnut@yahoo.com> - 2013-04-09 23:44 -0700
Re: While loop help Larry Hudson <orgnut@yahoo.com> - 2013-04-10 20:00 -0700
Re: While loop help jmfauth <wxjmfauth@gmail.com> - 2013-04-09 12:19 -0700
csiph-web