Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #67135 > unrolled thread
| Started by | Chris Angelico <rosuav@gmail.com> |
|---|---|
| First post | 2014-02-27 21:41 +1100 |
| Last post | 2014-02-28 14:36 +1000 |
| Articles | 2 — 2 participants |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: end quote help for a newbie Chris Angelico <rosuav@gmail.com> - 2014-02-27 21:41 +1100
Re: end quote help for a newbie alex23 <wuwei23@gmail.com> - 2014-02-28 14:36 +1000
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-02-27 21:41 +1100 |
| Subject | Re: end quote help for a newbie |
| Message-ID | <mailman.7418.1393497723.18130.python-list@python.org> |
On Thu, Feb 27, 2014 at 9:30 PM, Peter Clark <artomishka@yahoo.co.uk> wrote:
> Hi, I have just started trying to use python version 3, under windows XP, I
> have got a simple script (attached) to run as I want in Interpreter mode.
> It is saved as a .py file. If I double click on the file the python screen
> opens and appears to be waiting for input but the cursor just sits there
> without doing anything but blink. I haven't found any .py program which does
> anything except open and close the python window, or occasionally accepting
> input with no response.
In future, it'd be easier for us if you include the text inline. It's
not particularly long, so I'll just do that for you here.
# Dragons and dungeons, based on CP/M program messages from ca. 1966
# This version designed and produced by peter clark beginning in December 2013
def startandload(n): # introduce program and allow messages to be
loaded/amended
x = str(input("Welcome Adventurer, what is your name?"))
if x==('load'):
y = str(input("messages, places or things?"))
if y in("messages", "places","things"):
print("OK")
else: print("Wrong")
if x==('restart'):
y = str(input("game reference"))
if y in("messages", "places","things"):
print("*** to be done - load and restart game ***")
else: print("Wrong")
while True:
startandload
The problem is right at the end: you don't actually call the function.
You always need parentheses to call a function. I'm also a bit
confused as to your reason for running a function called
"startandload" (which seems to be initialization) in an infinite loop;
you possibly just want to call it once.
Note that input() already returns a string, so passing it through
str() doesn't do anything.
ChrisA
[toc] | [next] | [standalone]
| From | alex23 <wuwei23@gmail.com> |
|---|---|
| Date | 2014-02-28 14:36 +1000 |
| Message-ID | <lep3o9$3b5$1@dont-email.me> |
| In reply to | #67135 |
On 27/02/2014 8:41 PM, Chris Angelico wrote:
> On Thu, Feb 27, 2014 at 9:30 PM, Peter Clark <artomishka@yahoo.co.uk> wrote:
> # Dragons and dungeons, based on CP/M program messages from ca. 1966
> # This version designed and produced by peter clark beginning in December 2013
> def startandload(n): # introduce program and allow messages to be
> loaded/amended
> x = str(input("Welcome Adventurer, what is your name?"))
> if x==('load'):
> y = str(input("messages, places or things?"))
> if y in("messages", "places","things"):
> print("OK")
> else: print("Wrong")
> if x==('restart'):
> y = str(input("game reference"))
> if y in("messages", "places","things"):
> print("*** to be done - load and restart game ***")
> else: print("Wrong")
>
> while True:
> startandload
>
>
> The problem is right at the end: you don't actually call the function.
> You always need parentheses to call a function.
`startandload` also takes a parameter that doesn't seem to be used.
> I'm also a bit
> confused as to your reason for running a function called
> "startandload" (which seems to be initialization) in an infinite loop;
> you possibly just want to call it once.
Or perhaps:
if __name__ == '__main__':
startandload()
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web