Note that there are some explanatory texts on larger screens.

plurals
  1. POCode unexpectedly breaking
    primarykey
    data
    text
    <p>This is Python 3. In the event that a user has 0 points remaining in the pool, and has taken points from a key value and added them back into the pool, the program then breaks. This is confusing me because at this point pool > 0 and the first while loop should kick in, but it does not. Can anyone provide any explanation as to why? </p> <p>PS- general code critique also appreciated. New to this. </p> <pre><code>pool = 30 attr = {'Strength' : 0, 'Health' : 0, 'Wisdom' : 0, 'Dexterity' : 0} while pool &gt; 0: print('\t\t Time to spend some points! You have', pool, 'to spend') spend = input('Where would you like to spend your points?') if spend in attr: amount = int(input('How many points would you like to spend?')) if amount &gt; pool: print('You do not have that many points! You have', pool, 'points!') else: attr[spend] = amount pool -= amount print(attr) else: print('Not a valid input. Please correct.') print('\t\t You have no more points! Add some to the pool!') while pool == 0: confirm = input('Would you like to add points back into the pool?') if confirm == 'y': take = input('Where would you like to take points from?') if take in attr: number = int(input('How many points would you like to take?')) if attr[take] &gt;= number: pool += number attr[take] -= number print ('There are now', pool, 'points remaining') elif attr[take] &lt; number: print('You dont have enough points to do that! You have', attr[take], 'points in', take) else: print('Please make a valid selection.') elif confirm == 'n': print('Goodbye!') break </code></pre>
    singulars
    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.
    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