Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #47647
| Newsgroups | comp.lang.python |
|---|---|
| Date | 2013-06-11 00:25 -0700 |
| References | <af6709e3-b446-443a-abe1-5f80d0c30387@googlegroups.com> |
| Message-ID | <9d040c46-b78e-4705-bc13-a486b5922825@googlegroups.com> (permalink) |
| Subject | Re: Simple program question. |
| From | russ.pobox@gmail.com |
input() is a function which returns a string. You can assign this return value to a variable. That's what variables are for.
option = input()
Now you can use the variable named option in place of all those calls to input().
i.e:
...instead of..
if input() == 'parry':
# etc
...do this...
option = input()
if option == 'parry':
# etc
elif option == 'whatever':
# etc
Back to comp.lang.python | Previous | Next — Previous in thread | Find similar | Unroll thread
Simple program question. eschneider92@comcast.net - 2013-06-09 20:06 -0700 Re: Simple program question. Chris Angelico <rosuav@gmail.com> - 2013-06-10 13:33 +1000 Re: Simple program question. eschneider92@comcast.net - 2013-06-10 23:47 -0700 Re: Simple program question. russ.pobox@gmail.com - 2013-06-11 00:25 -0700
csiph-web