def fact(n):
if <= 1: #If the inequality does not go in, a compilation error will be left.
return 1
else:
return n * fact(n-1)
print(fact(4))
As I wrote in the comment above, there is a compilation error when only '=' without an inequality sign is entered, so can you tell me why?
if문
The same is not =
in most languages, but ==
.
Try ==
.
def fact(n):
if n == 1: #If the inequality does not go in, a compilation error will be left.
return 1
else:
return n * fact(n-1)
print(fact(4))
© 2024 OneMinuteCode. All rights reserved.