[Tutor] New 2 Python- Script 'kill' function/Ubuntu File Browser hide hidden files

Ian Egland ian505 at gmail.com
Sun Jan 13 21:17:21 CET 2008


Hello, I am new to Python (and OO programming in general) and I have a
script that I made through a tutorial.

# -*- coding: utf-8 -*-
# Copyright (C) 2007-2008 Ian Egland
# From the Non-Programmer's Guide to Python By Josh Cogliati
# 5.3 Exercise 1
# Modify the password guessing program to keep track of how many times the
user has entered the password wrong.
# If it is more than 3 times, print "That must have been complicated."


tries = 3
password = "What is the password?"
while password != "thepassword":
    print "You have", tries, "remaining."
    print "What is the password?"
    password = raw_input("> ")
    if password == "thepassword":
        print "You got the password in only", 3 - tries, "tries!"
    else:
        tries = tries - 1
        if tries == 0:
            print "Sorry... but that was wrong. (again) Your not as smart as
I thought..."
        else:
            print "I am sorry, that was incorrect. Please try again."
            quit

Now I cant see anything wrong with it... except that I don't think that quit
is the right function as when I run it this happens.

Python 2.5.1 (r251:54863, Oct  5 2007, 13:36:32)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "copyright", "credits" or "license()" for more information.

    ****************************************************************
    Personal firewall software may warn about the connection IDLE
    makes to its subprocess using this computer's internal loopback
    interface.  This connection is not visible on any external
    interface and no data is sent to or received from the Internet.
    ****************************************************************

IDLE 1.2.1      ==== No Subprocess ====
>>>
You have 3 remaining.
What is the password?
> is this it?
I am sorry, that was incorrect. Please try again.
You have 2 remaining.
What is the password?
> really?
I am sorry, that was incorrect. Please try again.
You have 1 remaining.
What is the password?
> omg one more left
Sorry... but that was wrong. (again) Your not as smart as I thought...
You have 0 remaining.
What is the password?
> ...huh?
I am sorry, that was incorrect. Please try again.
You have -1 remaining.
What is the password?
> lol
I am sorry, that was incorrect. Please try again.
You have -2 remaining.
What is the password?
>


I am using the while function, so I know that it will loop the script
forever unless I kill the application, but I don't know the command to kill
it.

Also, I am doing this in Ubuntu linux and hidden files are defined as
.filename. However, they are displayed in IDLE- so I have to scroll past
about 5 columns of hidden folders till I get to the 'visible' ones, which
contain my scripts. Any ideas on how to get IDLE not to reconize any
file/folders with the prefix '.'?

Thanks a million. I really am a nooB.

-- 
-Ian
My Website: http://www.64digits.net/
My Signature Page: http://www.64digits.net/signature/
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/tutor/attachments/20080113/9743a722/attachment.htm 


More information about the Tutor mailing list