[Chicago] beginner help - role playing game

Alan Stern alans at risingrealty.com
Sun Dec 5 19:51:23 CET 2010


input("\n\nHow many points do you want to assign to " + attributes[x] + " ?")
Thanks.  This definitely seems to fix the problem but I don't understand functionally why  this '+' works but  the commas don't.  I don't think the book have covered plus signs being used in this way before.

Any insight as to what direction I should go from here to complete the challenge? Pretty sure  I will need a while loop the covers when points are under 30 but other than that, I'm lost.


______________________
Alan Stern

Rising Realty
1820 W. Webster Ave #307
Chicago, IL 60614

(W)773-395-9999
(F)773-395-9553
(C)773-502-2556

From: chicago-bounces+alans=risingrealty.com at python.org [mailto:chicago-bounces+alans=risingrealty.com at python.org] On Behalf Of Francesca Slade
Sent: Sunday, December 05, 2010 12:40 PM
To: The Chicago Python Users Group
Subject: Re: [Chicago] beginner help - role playing game

I think you can also construct the string in the input function:

input("\n\nHow many points do you want to assign to %s? " % attributes[x])

or

input("\n\nHow many points do you want to assign to " + attributes[x] + " ?")
On Sun, Dec 5, 2010 at 12:31 PM, Chad Glendenin <chad at glendenin.com<mailto:chad at glendenin.com>> wrote:
The input() function only takes one param: a prompt string. To do what
you're trying to do, you need to build the string first, then pass the
finished string to the input() function. If you're in the python
intrepreter, you can do

>>> help(input)

to see the documentation. (Also, check out the raw_input() function.)

You probably want something like:

prompt = "\n\nHow many points do you want to assign to %s? " % attributes[x]
input(prompt)


On Sun, Dec 5, 2010 at 12:12 PM, Alan Stern <alans at risingrealty.com<mailto:alans at risingrealty.com>> wrote:
> Hi all.  My name is Al Stern.  I am an absolute beginner to programming and
> based on what I'd read, decided to try Python as my 1st language.  I am
> starting with a book called Python Programming for the Absolute Beginner by
> Michael Dawson.  The book has been pretty good and up to this point, I have
> grasped all the concepts it has covered.  At the end of each chapter, there
> are a number of challenges you need to complete before moving on.  Problem
> is, I have gotten stumped on one in Chapter 5: Lists and Dictionaries.
>
>
>
> I'm not sure exactly how this mailing list works but was hoping someone here
> could give me some insight as to how to proceed.  Apologies if I am not
> posting the following in the correct format.  I just copied and pasted.)
> Feel free to point me in the right direction if there are instructions as to
> how to do it.
>
>
>
> Here is the challenge: Write a Character Creator program for a role-playing
> game. The player should be given a pool of 30 points to spend on four
> attributes: Strength, Health, Wisdom, and Dexterity. The >player should be
> able to spend points from the pool on any attribute and should also be able
> to take points from an attribute and put them back into the pool.
>
>
>
> I think I did ok setting up the variables but haven't figured out where to
> go from there.
>
>
>
> Here is what I have (along with my latest error message).  Thanks in
> advance.
>
>
>
> # character creator / role playing game
>
> # have 30 total points to work with
>
>
>
> # set variables
>
>
>
> attributes = ["strength", "health", "wisdom", "dexterity"]
>
> points = [0,0,0,0]
>
> MAX_POINTS = 30
>
> available_points = MAX_POINTS - sum(points)
>
>
>
> print("""
>
> Our hero will need strength, health, wisdom and dexterity to survive.
>
> You will have a limited amount of points to 'spend' on these attributes.
>
> Use them wisely.  His life depends on it.
>
> """
>
> )
>
>
>
> # point allocation
>
>
>
> print ("You have", available_points, "points available to use.")
>
>
>
> for x in range(len(attributes)):
>
>   print ("\t",attributes[x], points[x])
>
>
>
> for x in range(len(attributes)):
>
>     point_choice = input("\n\nHow many points do you want to assign to ",
> attributes[x] , "?: ")
>
>
>
> My error is:
>
>
>
> Traceback (most recent call last):
>
>   File "C:/Users/Public/Documents/My Python programs/role_playing_game1.py",
> line 24, in <module>
>
>     point_choice = input("\n\nHow many points do you want to assign to ",
> attributes[x] , "?: ")
>
> TypeError: input expected at most 1 arguments, got 3
>
>
>
>
>
> ______________________
>
> Alan Stern
>
>
>
> Rising Realty
>
> 1820 W. Webster Ave #307
>
> Chicago, IL 60614
>
>
>
> (W)773-395-9999
>
> (F)773-395-9553
>
> (C)773-502-2556
>
>
>
> www.risingrealty.com<http://www.risingrealty.com>
>
> Statement of Confidentiality
>
> The contents of this e-mail message and its attachments are intended solely
> for the addressee(s) hereof. In addition, this e-mail transmission may be
> confidential and it may be subject to privilege protecting communications
> between attorneys or solicitors and their clients. If you are not the named
> addressee, or if this message has been addressed to you in error, you are
> directed not to read, disclose, reproduce, distribute, disseminate or
> otherwise use this transmission. Delivery of this message to any person
> other than the intended recipient(s) is not intended in any way to waive
> privilege or confidentiality.  If you have received this transmission in
> error, please alert the sender by reply e-mail; we also request that you
> immediately delete this message and its attachments, if any. Rising Realty
> reserve the right to monitor all e-mail communications through their
> networks.
>
>
>
>
>
> _______________________________________________
> Chicago mailing list
> Chicago at python.org<mailto:Chicago at python.org>
> http://mail.python.org/mailman/listinfo/chicago
>
>



--
about.me/ccg<http://about.me/ccg>
_______________________________________________
Chicago mailing list
Chicago at python.org<mailto:Chicago at python.org>
http://mail.python.org/mailman/listinfo/chicago

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/chicago/attachments/20101205/19f1d02d/attachment.html>


More information about the Chicago mailing list