2tbc1887
2tbc1887

Reputation: 3

1 Integer seems to be taking the value of another Python

In my code, the 'detentions' integer seems to be taking the value of the 'day' integer when calling new_week()

I have looked through the code and just cannot find what is causing it.

It is defined like:

def new_week(self, detentions, motivation):
  print(colored(detentions, 'yellow'))
  oldmotiv = motivation
  for i in range(0, detentions):
    motivation = motivation - 3
    print(colored("Detentions: " + str(detentions), 'yellow'))
    print(colored("Motivation: " + str(motivation), 'yellow'))

  print(colored("End of week summary: ", 'green'))
  lostmotiv = oldmotiv - motivation
  print(colored("You lost " + str(lostmotiv) + " motivation!", 'green'))
  detentions = 0

It is invoked like:

  print("It's the weekend! What would you like to do?")
  WorldSettings.new_week(detentions, day, motivation)
  again = input("Continue? yes, no ")
  again.lower()
  day = 1

Full code is here, on Repl.it

Upvotes: 0

Views: 45

Answers (1)

DWilches
DWilches

Reputation: 23015

In your code you are invoking the method as if it were a class method:

WorldSettings.new_week(detentions, day, motivation)

It should be as an instance method:

class_worldsettings.new_week(detentions, day, motivation)

Also, notice that you are invoking the method with 3 parameters, but your method is defined to only need 2 parameters (besides the elf`that is an implicit parameter):

def new_week(self, detentions, motivation)

So it should be:

def new_week(self, detentions, day, motivation)

Upvotes: 1

Related Questions