I think there are few errors in your code.
You just need to understand and correct few errors in your code.
num=int(input("Enter a number:"))
fact=1
if(num==0):
fact=1
else:
for i in range(1,num+1):
fact=fact*i
print("Factorial of",num,"is",fact)
1.Before if statement, you have to declare a fact.
2.It is better to use if-else statement.
3.In for Statement,The range should be num+1.because the ending index is not considered in the loop.