end quote help for a newbie

Chris Angelico rosuav at gmail.com
Thu Feb 27 05:41:53 EST 2014


On Thu, Feb 27, 2014 at 9:30 PM, Peter Clark <artomishka at 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



More information about the Python-list mailing list