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:"))
for i in range(1,num+1):
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.