Really your page is useful for me... On 13-Dec-2013 11:01 PM, <tutor-requ...@python.org> wrote:
> Send Tutor mailing list submissions to > tutor@python.org > > To subscribe or unsubscribe via the World Wide Web, visit > https://mail.python.org/mailman/listinfo/tutor > or, via email, send a message with subject or body 'help' to > tutor-requ...@python.org > > You can reach the person managing the list at > tutor-ow...@python.org > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Tutor digest..." > > > Today's Topics: > > 1. Re: Coding for a Secret Message in a Game (Steven D'Aprano) > 2. Re: Coding for a Secret Message in a Game (spir) > 3. Using python's smtp server (Vincent Davis) > 4. Re: Using python's smtp server (Mark Lawrence) > 5. Re: Using python's smtp server (Vincent Davis) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Fri, 13 Dec 2013 22:00:02 +1100 > From: Steven D'Aprano <st...@pearwood.info> > To: tutor@python.org > Subject: Re: [Tutor] Coding for a Secret Message in a Game > Message-ID: <20131213105959.GL29356@ando> > Content-Type: text/plain; charset=us-ascii > > On Thu, Dec 12, 2013 at 11:10:31PM -0500, Sky blaze wrote: > > > Here's the code I currently have so far: > > print("===INSTRUCTIONS===") > > input(">> ") > > Are you using Python 3? Is so, that's fine, but in Python 2 you should > use raw_input instead. > > > print("When you see a \'>>\', hit Enter to advance the text.") > > There's no need for the backslashes to escape the quotes. Python uses > two different quotes especially so you can put one sort inside the > other: > > "Here you don't need to escape the single quote." > 'He turned to me and said, "Is that a fact?"' > > > > start = False #This is the start screen check > > print("Type \"start\" to begin.") #Command message to start the game > > start_prompt = input("> ") #Command prompt to start the game > > while start != True: #Infinite loop that doesn't end until "start" is > typed > > if start_prompt == "start": > > start = True #Continues from the title screen > > First off, let me show you how I would do this command prompt without > changing the message. > > answer = "" > while answer != 'start': > print("Type 'START' to begin.") > # Ignore leading and trailing spaces, and UPPER/lower case. > answer = input("> ").strip().lower() > > > That will loop forever, or until the user types "start", regardless of > case. "StArT" or any other combination will be accepted, as will spaces > at the start or end of the word. > > How do we add a changing prompt? We need to know when to change the > prompt, and to do that, we need to count how many times we've been > around the loop. Here's my first version, which changes the prompt only > once: > > answer = "" > prompt = "Type 'START' to begin." > count = 0 > while answer != 'start': > count += 1 > if count == 10: > prompt = "Y U NO TYPE 'START'???" > print(prompt) > # Ignore leading and trailing spaces, and UPPER/lower case. > answer = input("> ").strip().lower() > > > That's okay for what it is, but what if you wanted more than two > different prompts? Here's a third version which uses a function that > returns the required prompt. > > > def get_prompt(loop_number): > if loop_number == 1: > return "Enter 'START' to begin the game." > if 2 <= loop_number < 5: > return ("I'm sorry, I don't know that response." > " Enter 'START' to begin the game.") > if 5 <= loop_number < 10: > return "Type the word 'START' then press the Enter key." > return "Y U NO TYPE 'START'???" > > > answer = "" > count = 0 > while answer != 'start': > count += 1 > print(get_prompt(count)) > # Ignore leading and trailing spaces, and UPPER/lower case. > answer = input("> ").strip().lower() > > > > -- > Steven > > > ------------------------------ > > Message: 2 > Date: Fri, 13 Dec 2013 12:40:02 +0100 > From: spir <denis.s...@gmail.com> > To: tutor@python.org > Subject: Re: [Tutor] Coding for a Secret Message in a Game > Message-ID: <52aaf212.40...@gmail.com> > Content-Type: text/plain; charset=UTF-8; format=flowed > > On 12/13/2013 05:10 AM, Sky blaze wrote: > > Hi, I'm a newbie Python programmer. I was introduced to Python via the > Hour > > of Code, and after completing all three of Grok Learning's tutorials, I > was > > inspired to create a text-based RPG adventure. I composed this e-mail > after > > searching for a forum for Python, and this address showed up in one of > the > > results. > > > > Due to my inexperience with Python, I'm having trouble creating a code > for > > one of the things I wanted to do for the game. The game starts out on a > > "title screen" with a message saying, "Type 'start' to begin!" I thought > > it'd be amusing to have the message change after the player types > something > > other than "start" at least 10 times. I've attempted numerous times to > code > > this, but all of them have failed. Could you help me with the coding? It > > should look something like this in the end: > > > > Welcome to Prog Land! > > Others have answered about counting in a loop. Here are a few other > comments: > > As you obviously have understood by yourself, one wonderful thing with > programming is that we can do what we want, as we want it. We can invent > worlds, > like what you have in mind for an RPG. It frees imagination. > > However, like any complicated domain, there is problem of dimension. If > you want > to enjoy programming for a long time, instead of being quickly fed up, > maybe > consider sizing your projects according to your knowledge & experience -- > as > well as energy & time available. > > A trick is to explore and develop little bits that can be run or tested > independantly, while they let you discover and learn how to do things. > Something > challenging enough to be fun, but that won't let you in the dark for > years. This > user-input problem you chose is a good example for start, i guess. > > Some possibilities; how to: > * simulate dice, like 2d10, and have events show up with given probability > * define an output format for user interaction > * define a character/monster with given properties (strength, speed, > HPs...) > * store objects and special capacities on beeings (units) > * represent a playing land with rooms and pathes (dungeon) > * find a path > * connect objects/capacities with actions (a key for a door open) > * represent the logic of game events (when this and that, then thut) > * represent the logic of game progress (they've reached this point of the > objective) > ? > > Thanks for sharing your excitement! If you go on your RPG (and even if > not), > this mailing list is here for help. You'll have to learn about functions of > different kinds and various data structures, how to have them serve you, > not the > opposite, how to let them interact while not ending up with a big mess out > of > comprehension... > > Denis > > > ------------------------------ > > Message: 3 > Date: Fri, 13 Dec 2013 09:48:36 -0700 > From: Vincent Davis <vinc...@vincentdavis.net> > To: tutor@python.org > Subject: [Tutor] Using python's smtp server > Message-ID: > < > calyjzzxdzpyxuzdhphcz7fahl2nlblwi+uhgac3gmoctzv3...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > I have an app that generates a file one a day and would like to email it > using python's SMTP server. > http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer > The documentation is kinda sparse and I cant seem to find any good > examples. > > Basically what I want to do; when my app runs it would initiate a SMTP > server, send the attachment and shutdown the SMTP after. > > Vincent Davis > 720-301-3003 > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20131213/eb2fb581/attachment-0001.html > > > > ------------------------------ > > Message: 4 > Date: Fri, 13 Dec 2013 17:07:47 +0000 > From: Mark Lawrence <breamore...@yahoo.co.uk> > To: tutor@python.org > Subject: Re: [Tutor] Using python's smtp server > Message-ID: <l8fet4$n93$2...@ger.gmane.org> > Content-Type: text/plain; charset=ISO-8859-1; format=flowed > > On 13/12/2013 16:48, Vincent Davis wrote: > > I have an app that generates a file one a day and would like to email it > > using python's SMTP server. > > http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer > > The documentation is kinda sparse and I cant seem to find any good > examples. > > > > Basically what I want to do; when my app runs it would initiate a SMTP > > server, send the attachment and shutdown the SMTP after. > > > > Vincent Davis > > 720-301-3003 > > > > Please refer to the answer you've already received on the main Python > mailing list. > > -- > My fellow Pythonistas, ask not what our language can do for you, ask > what you can do for our language. > > Mark Lawrence > > > > ------------------------------ > > Message: 5 > Date: Fri, 13 Dec 2013 10:28:46 -0700 > From: Vincent Davis <vinc...@vincentdavis.net> > To: Mark Lawrence <breamore...@yahoo.co.uk> > Cc: tutor@python.org > Subject: Re: [Tutor] Using python's smtp server > Message-ID: > <CALyJZZXywoQSAG-kiNb05tjATiPP0WSkJRdTab7= > i8dy61b...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > Mark, > Thanks mark, It had been about 15hr since I posted to > python-list@python.organd had not seen a response so I thought I would > try > tutor.python.org. > Well I got a response now, not that it helped, but I respond on that list. > Thanks again. > > Vincent Davis > 720-301-3003 > > > On Fri, Dec 13, 2013 at 10:07 AM, Mark Lawrence <breamore...@yahoo.co.uk > >wrote: > > > On 13/12/2013 16:48, Vincent Davis wrote: > > > >> I have an app that generates a file one a day and would like to email it > >> using python's SMTP server. > >> http://docs.python.org/2/library/smtpd.html#smtpd.SMTPServer > >> The documentation is kinda sparse and I cant seem to find any good > >> examples. > >> > >> Basically what I want to do; when my app runs it would initiate a SMTP > >> server, send the attachment and shutdown the SMTP after. > >> > >> Vincent Davis > >> 720-301-3003 > >> > >> > > Please refer to the answer you've already received on the main Python > > mailing list. > > > > -- > > My fellow Pythonistas, ask not what our language can do for you, ask what > > you can do for our language. > > > > Mark Lawrence > > > > _______________________________________________ > > Tutor maillist - Tutor@python.org > > To unsubscribe or change subscription options: > > https://mail.python.org/mailman/listinfo/tutor > > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: < > http://mail.python.org/pipermail/tutor/attachments/20131213/96d5ed13/attachment.html > > > > ------------------------------ > > Subject: Digest Footer > > _______________________________________________ > Tutor maillist - Tutor@python.org > https://mail.python.org/mailman/listinfo/tutor > > > ------------------------------ > > End of Tutor Digest, Vol 118, Issue 64 > ************************************** >
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: https://mail.python.org/mailman/listinfo/tutor