0

Hi just starting with python, been in it for a few days and I design an discord bot. One of fucntions I wanna use is kind of economy. But when I print out function to show balance I got another line with "NONE" and I got no clue where it came from. Here is my code.

economy_currency = '$'


class Economy:
    def __init__(self, p, n, m):
        self.position = p
        self.name = n
        self.money = int(m)

    def balance(self):
            print(self.name + ' your balance is ' + economy_currency + str(self.money))


najzik = Economy(1, 'Najzik', "200")
print(najzik.balance())

and the output is

Najzik your balance is $200
None # this is coming from where?? 
najzik
  • 1
  • 3
    The method `balance` does not return anything, which is a synonym to returning `None`. – bereal Dec 05 '20 at 17:26
  • 2
    you are printing a print ... `print` has type `None` because it is just printing for you something to see ... – ombk Dec 05 '20 at 17:27
  • Inside your `balance` function replace `print` with `return`. Reasoning is in the comments above. – PM 77-1 Dec 05 '20 at 17:29

0 Answers0