+ 1
I started learning python and Im struggling with functions. Whats wronge with this code?
def compare(value,money): total=money-value if money>value: return total else: print("Cannot Afford") print(compare(50,5000)) Also, I apologize if it is just a stupid mistake I didn't notice
5 Antworten
+ 3
The return statement should be indented
+ 2
I'm also rather new at Python, but I believe the problem is that the "return total" line should be indented. When that is done your code compiles.
+ 1
you need read function in python as more detail , it's best way for you
best regards
+ 1
Thanks a lot to everyone!
+ 1
def compare(value,money):
total=money-value
if money>value:
return total
else:
print("cannot afford")
print(compare(50,5000))