New to python why is my script not working?

Im using this script to try and make a property called percent never equal more than 100 or less 0. Here’s what I got.



import GameLogic as l
cont = l.getCurrentController() 
obj = cont.owner
percent = obj['percent']

if percent > 100:
    percent = 100
    

This script is attached to an Always sensor. Why does it allow me to set percent higher than 100?

Im using 2.56/2.57.

You need to assign the value back to the property, add this at the end:

obj[‘percent’] = percent

Thank you kindly.