<html>
  <head>
    <meta content="text/html; charset=ISO-8859-1"
      http-equiv="Content-Type">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    On 8/2/2011 11:39 PM, Alexander Quest wrote:
    <blockquote
cite="mid:CAHgjEe3hpo5CkoFphhb8KSUpmU3myfrVcHp_KqwN7nYXZgmjLQ@mail.gmail.com"
      type="cite">Hey Bob- thanks for the reply. Here is a more complete
      part of that code section (the ellipses are parts where I've
      deleted code because I don't think it's important for this
      question):<br>
    </blockquote>
    <br>
    Please always reply-all so a copy goes to the list.<br>
    <br>
    Thanks for posting more code &amp; traceback<br>
    <br>
    I forgot to mention earlier - tell us which version of Python you
    are using (this looks like version 3)<br>
    <br>
    You did not answer all my questions! How come? Please do so now.<br>
    <blockquote
cite="mid:CAHgjEe3hpo5CkoFphhb8KSUpmU3myfrVcHp_KqwN7nYXZgmjLQ@mail.gmail.com"
      type="cite"><br>
      &nbsp;<br>
      _____________________________________________________________<br>
      attributes = [("strength", 0), ("health&nbsp; ", 0), ("wisdom&nbsp; ", 0),
      ("dexterity", 0)]<br>
      .....<br>
      .....<br>
      .....<br>
      print(<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; """<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 - Strength<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2 - Health<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 3 - Wisdom<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4 - Dexterity<br>
      <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Any other key - Quit<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; """<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; selection = input("Selection: ")<br>
      if selection == "1" or selection == "2" or selection == "3" or
      selection == "4":<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("You have ", points, "points available.") <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; how_many = input("How many would you like to add
      to this attribute?: ")<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; while how_many &lt; 0 or how_many &gt; 30 or
      how_many == "":&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # Because max points
      available is 30, and entering less than 0 does not make sense. <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("Invalid entry. You have ", points,
      "points available.")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; # If the user
      enters a number less than 0, greater than 30, or just presses
      enter, it loops.<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; how_many = input("How many would you like to
      add to this attribute?: ")<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print("Added ", points, "to ",
      attributes[selection-1][0], "attribute.")&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      # Here is where I try to add the number of points to the value,
      based on what the user entered.<br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; points = points -
      how_many&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      # I subtract the number of points added from the total points
      available. <br>
      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; attributes[selection-1][1] +=
      how_many&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
      # I add the number of points the user selected to the variable
      selected. <br>
      <br>
      &nbsp;<br>
__________________________________________________________________________<br>
      <br>
      <br>
      Here's the traceback I get:<br>
      <br>
      Traceback (most recent call last):<br>
      &nbsp; File "C:\Users\Alexander\Desktop\Python Practice\Ch05-2.py",
      line 54, in &lt;module&gt;<br>
      &nbsp;&nbsp;&nbsp; print("Added ", points, "to ", attributes[selection-1][0],
      "attribute.")<br>
      TypeError: unsupported operand type(s) for -: 'str' and 'int'<br>
_________________________________________________________________________<br>
      <br>
      Thanks for any help. I understand that I can't change tuples
      directly, but is there a way to change them indirectly (like
      saying attribute.remove[x] and then saying attribute.append[x]
      with the new variable? But this seems to take out both the string
      and the value, when I only want to increase or decrease the value
      for one of the 4 strings, strength, health, wisdom, or dexterity).<br>
    </blockquote>
    <br>
    DON'T USE TUPLES. WHY DO YOU INSIST ON THEM?<br>
    <blockquote
cite="mid:CAHgjEe3hpo5CkoFphhb8KSUpmU3myfrVcHp_KqwN7nYXZgmjLQ@mail.gmail.com"
      type="cite"><br>
      <div class="gmail_quote">
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">
          <br>
          What does the error message( unsupported operand type(s) for
          -: 'str' and 'int')&nbsp; tell you? </blockquote>
      </div>
    </blockquote>
    <br>
    <blockquote
cite="mid:CAHgjEe3hpo5CkoFphhb8KSUpmU3myfrVcHp_KqwN7nYXZgmjLQ@mail.gmail.com"
      type="cite">
      <div class="gmail_quote">
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">Why would selection be a string rather
          than an integer? </blockquote>
      </div>
    </blockquote>
    <br>
    <blockquote
cite="mid:CAHgjEe3hpo5CkoFphhb8KSUpmU3myfrVcHp_KqwN7nYXZgmjLQ@mail.gmail.com"
      type="cite">
      <div class="gmail_quote">
        <blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt
          0.8ex; border-left: 1px solid rgb(204, 204, 204);
          padding-left: 1ex;">This has to do with how you obtain
          selection from the user.<br>
          <br>
          Why did you expect to be able to alter the value of a tuple
          element? Tuples are immutable! Use a list instead.<br>
          <br>
        </blockquote>
      </div>
    </blockquote>
    <br>
    <pre class="moz-signature" cols="72">-- 
Bob Gailer
919-636-4239
Chapel Hill NC</pre>
  </body>
</html>