Sep-29-2018, 09:34 AM
Assuming you have your indention correct (we can't tell, because you have not put BBCode tags around your code yet), then you are missing a
Here's a corrected version of your code, and also an alternative approach, as well as example usage. Note I changed int to int_ to avoid hiding the int type.
:
at the end of the if statement line. As mentioned, best not to use things Python already uses as your variable names.Here's a corrected version of your code, and also an alternative approach, as well as example usage. Note I changed int to int_ to avoid hiding the int type.
def powerTo(double, int_): if int_ >= 0: return double ** int_ else: return 0 def powerTo2(double, int_): return 0 if int_ < 0 else double ** int_ for num in range(-2, 4): print(powerTo(5, num), powerTo2(5, num))
I am trying to help you, really, even if it doesn't always seem that way