Reputation:
This is for my computer science class and I dont make the criteria. The idea is: Write a function named print_sum that accepts three numbers as parameters and prints the sum. First, write the print_sum function. Then, prompt the user for three inputs, and call your print_sum function on those inputs. I write:
def print_sum(a, b, c):
print('The sum:', int(a) + int(b) + int(c))
a = input('Enter the 1st number: ')
b = input('Enter the 2nd number: ')
c = input('Enter the 3rd number: ')
print_sum(a, b, c)
I do not meet the criteria: Check that the function is using the 3 parameters passed to it rather than the 3 inputs directly.
anyone able to correct what I am doing wrong? should be simple but I cannot figure it out
Upvotes: 2
Views: 2267
Reputation: 44713
While I think the clarity of the feedback you got is abhorrent at best, the reason this check is failing is likely because you've named your variables the same in both the scope of the function and the global scope.
As such, if you name them differently, you'll probably pass the check you referenced:
def print_sum(first, second, third):
print('The sum:', int(first) + int(second) + int(third))
a = input('Enter the 1st number: ')
b = input('Enter the 2nd number: ')
c = input('Enter the 3rd number: ')
print_sum(a, b, c)
Upvotes: 3