Note that there are some explanatory texts on larger screens.

plurals
  1. POTypeError: Can't convert 'int' object to str implicitly
    primarykey
    data
    text
    <p>I am trying to write a text game and I have run into an error in the function I am defining that lets you basically spend your skill points after you make your character. At first, the error stated that I was attempting to subtract a string from an integer in this part of the code:<code>balance - strength</code>. Obviously that was wrong so I fixed it with <code>strength = int(strength)</code>... but now I am getting this error which I have never seen before(new programmer) and I am stumped on what exactly it is trying to tell me and how I fix it.</p> <p>Here is my code for the part of the function that isn't working:</p> <pre><code>def attributeSelection(): balance = 25 print("Your SP balance is currently 25.") strength = input("How much SP do you want to put into strength?") strength = int(strength) balanceAfterStrength = balance - strength if balanceAfterStrength == 0: print("Your SP balance is now 0.") attributeConfirmation() elif strength &lt; 0: print("That is an invalid input. Restarting attribute selection. Keep an eye on your balance this time!") attributeSelection() elif strength &gt; balance: print("That is an invalid input. Restarting attribute selection. Keep an eye on your balance this time!") attributeSelection() elif balanceAfterStrength &gt; 0 and balanceAfterStrength &lt; 26: print("Ok. You're balance is now at " + balanceAfterStrength + " skill points.") else: print("That is an invalid input. Restarting attribute selection.") attributeSelection() </code></pre> <p>And here is the error I get when I get to this part of the code in the shell:</p> <pre><code> Your SP balance is currently 25. How much SP do you want to put into strength?5 Traceback (most recent call last): File "C:\Python32\APOCALYPSE GAME LIBRARY\apocalypseGame.py", line 205, in &lt;module&gt; gender() File "C:\Python32\APOCALYPSE GAME LIBRARY\apocalypseGame.py", line 22, in gender customizationMan() File "C:\Python32\APOCALYPSE GAME LIBRARY\apocalypseGame.py", line 54, in customizationMan characterConfirmation() File "C:\Python32\APOCALYPSE GAME LIBRARY\apocalypseGame.py", line 93, in characterConfirmation characterConfirmation() File "C:\Python32\APOCALYPSE GAME LIBRARY\apocalypseGame.py", line 85, in characterConfirmation attributeSelection() File "C:\Python32\APOCALYPSE GAME LIBRARY\apocalypseGame.py", line 143, in attributeSelection print("Ok. You're balance is now at " + balanceAfterStrength + " skill points.") TypeError: Can't convert 'int' object to str implicitly </code></pre> <p>Does anyone know how to solve this? Thanks ahead.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload