-3

I am new to programming, I started to learn python, I have downloaded VS code and Pycharm IDE to run python, my normal code is running successfully but when I define any function in the code , it does not show any output(does not show any error either). Please help me how can I resolve this. Thanks a lot

def get_taxes(earnings):
    if earnings < 12000:
        tax_owed = .25 * earnings
    else:
        tax_owed = .30 * earnings
    return tax_owed
    print(get_taxes(10000))
wkl
  • 77,184
  • 16
  • 165
  • 176
deeps
  • 1
  • 2
  • 1
    first show your code, please – Bohdan Aug 20 '22 at 11:47
  • Please show your code, and if you haven’t done so, please go through the Python tutorial or similar: https://docs.python.org/3/tutorial/ – wkl Aug 20 '22 at 11:49
  • Your `print` statement needs to be unindented. Right now it would be considered part of the `get_taxes` method. – wkl Aug 20 '22 at 18:45

1 Answers1

1

Functions must be called after they are defined, or else the code within does nothing. For example:

def print_hi(name):
    print("Hello", name)

would not return anything when run. You have to call it, like so:

print_hi("World")
  • I have added the code. Please have a look in this, it does not show any output. – deeps Aug 20 '22 at 14:01
  • In future, please format using Ctrl + K for easier readability. However, I ran the code and it returned 2500, so it does not appear to be an issue with the code. Perhaps an indentation or interpreter issue? I'm not sure. –  Aug 20 '22 at 14:21
  • @deeps If you look at your code, it seems to be an indentation issue. You have called get_prints() from within the function, but get_prints() is never called in the first place. To fix it, just remove the indentation on "print(get_prints())" and it should run! –  Aug 21 '22 at 01:26