-2
def func(num1, num2):
    """This function returns the sum of the numbers.
    :param num1: number
    :param num2: number
    :type num1: int
    :type num2: int
    return: the sum of the numbers
    rtype: int
    """
    return num1 + num2
    
func(10, 5) 
Paul H
  • 65,268
  • 20
  • 159
  • 136
anaki
  • 1
  • It works for me: https://trinket.io/python3/5b6ddf7e5b – Ryan Fu Jan 02 '22 at 18:12
  • You need `print(str(func(10, 5)))` to actually see your output. Otherwise, I am also not getting any error – Ryan Millares Jan 02 '22 at 18:12
  • 3
    The error is as clear as it gets - don't mix tabs and spaces for indentation. The recommendation is to use spaces (4 per level). – buran Jan 02 '22 at 18:13
  • In your file, you have used both space and tab characters as indentation. Python wants you to pick one and stick with it. I prefer 4 spaces. – Paul H Jan 02 '22 at 18:13
  • In general, the answer to "what causes an error with the message X?" is that your code is/does X, and shouldn't. If you don't understand that part of the message, itself, then you should start by asking why you don't understand it. Do you know what the words mean? If not, look them up. Do you understand why they describe the code? If not, try to figure that out. You might have to start by looking up the standards and thinking about the underlying principles. For example: why is indentation used in Python code? What does it mean? How may you do it, according to the documentation? – Karl Knechtel Jan 02 '22 at 18:17
  • As others have stated, the python interpreter doesn't like tabs and spaces mixed in the same file. Tabs are often replaced with 4 spaces. Or sometimes 5. Usually you can control this in your text editor/IDE with a "replace tabs with spaces" as you type option. And many editors have a function that will go through your file and replace tabs with spaces in the whole file to fix an existing file. – bfris Jan 02 '22 at 18:42

1 Answers1

-1

The code works for me. Maybe you forget to use tabs in the function?

Andre Bormans
  • 39
  • 1
  • 3