Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Modifying Class values
#2
self.level is an integer, which is immutable. Immutable data types are assign by value, which mean a copy is made. So level has the same value as self.level after line 30, but level shares no connection to the value of self.level. So when you change the value of level on line 32, it has no effect on the value of self.level.

You want to change line 32 to self.level += 1, and delete line 30.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
Modifying Class values - by Tridium - Aug-05-2019, 09:23 PM
RE: Modifying Class values - by ichabod801 - Aug-05-2019, 09:52 PM
RE: Modifying Class values - by Tridium - Aug-05-2019, 10:29 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Modifying Classes Tridium 4 6,813 Aug-03-2019, 05:41 PM
Last Post: Tridium

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020