I was going through the Python tutorials and I decided to create a little exercise for myself with the “Lambda” tool. It’s a basic square root calculator. However, when I try to run it, it doesn’t return a number. Here’s how it looks so far.
x = int(raw_input("Enter number:"))
def power(n):
return lambda x: x**n
sqrt = power(0.5)
sqrt(x)
Why doesn’t it work? If I’ve done made some sort of horrible mistake, please alert me. Remember, I’m a newbie so no complicated language please.
What do you mean by it doesn’t work? Did you just forget to do:
instead of just
?