Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54166
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!news.linkpendium.com!news.linkpendium.com!panix!gordon |
|---|---|
| From | John Gordon <gordon@panix.com> |
| Newsgroups | comp.lang.python |
| Subject | Re: Need help to sort out the below code... |
| Date | Sat, 14 Sep 2013 14:42:51 +0000 (UTC) |
| Organization | PANIX Public Access Internet and UNIX, NYC |
| Lines | 48 |
| Message-ID | <l11slb$ekd$1@reader1.panix.com> (permalink) |
| References | <9f6d4a88-4ae4-4e61-9f73-c074ec3f487f@googlegroups.com> |
| NNTP-Posting-Host | panix2.panix.com |
| X-Trace | reader1.panix.com 1379169771 14989 166.84.1.2 (14 Sep 2013 14:42:51 GMT) |
| X-Complaints-To | abuse@panix.com |
| NNTP-Posting-Date | Sat, 14 Sep 2013 14:42:51 +0000 (UTC) |
| User-Agent | nn/6.7.3 |
| Xref | csiph.com comp.lang.python:54166 |
Show key headers only | View raw
In <9f6d4a88-4ae4-4e61-9f73-c074ec3f487f@googlegroups.com> mnishpsyched <mnish1984@gmail.com> writes:
> print """
> Please select from the following menu:
> 1. pizza
> 2. steak
> 3. pasta
> 4. burger
> type in any number from above for selection..
> """
> pz = raw_input()
> pz = int(pz)
> st = raw_input()
> st = int(st)
> ps = raw_input()
> ps = int(ps)
> bg = raw_input()
> bg = int(bg)
> but my program doesn't output the selection once i type in any number
> from the list..Please help me to sort it out...
That's because you're calling raw_input() four times, thus the user must
type in a number four times.
You probably want something like this:
user_choice = raw_input()
user_choice = int(user_choice)
if user_choice == 1:
print "You have selected", user_choice, ".pizza"
....
....
elif user_choice == 2:
print "You have selected", st, ".Steak"
....
....
--
John Gordon A is for Amy, who fell down the stairs
gordon@panix.com B is for Basil, assaulted by bears
-- Edward Gorey, "The Gashlycrumb Tinies"
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Need help to sort out the below code... mnishpsyched <mnish1984@gmail.com> - 2013-09-13 23:34 -0700 Re: Need help to sort out the below code... Terry Reedy <tjreedy@udel.edu> - 2013-09-14 03:50 -0400 Re: Need help to sort out the below code... Jugurtha Hadjar <jugurtha.hadjar@gmail.com> - 2013-09-14 09:38 +0100 Re: Need help to sort out the below code... John Gordon <gordon@panix.com> - 2013-09-14 14:42 +0000
csiph-web