Python Python Basics Functions and Looping Create a Function

Splotch_ P
PRO
Splotch_ P
Pro Student 1,589 Points

I am having a hard time storing the value of the squared number as a result.

If anyone can show me a fast way to write this correctly I would really appreciate it

squaring.py
def square(num):
    print (num * num)
Splotch_ P
Splotch_ P
Pro Student 1,589 Points

Thank you for the responses. I figured out that I wasn’t storing the square of 3 as a result after passing in the arguement.

2 Answers

Alexander Davison
Alexander Davison
65,246 Points

You need to return, not print.

print just prints data onto the screen, but return allows you to return the data for further processing.

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 33,815 Points

The challenge specifies the parameter name is "number" but I think it works either way.

def square(number):
    return (number * number)