# I am trying to do some basic challenges

 Simon Piras · October 8, 2014 Hello Python friends!I am trying to practice and review the basis of python. I am using Python 3.4.I want to write a program that can compute factorial. I tried various ways (with a function or in the following fashion) but I either fail or get an infinite loop.Would someone be kind enough to give me pointers (but not the whole answer please!)print("Hello user, give me a value!")x = int(input())if x == 0:    print("1")elif (x < 0):    print("No that's impossible")else:    while x>0:        (x*(x-1))        print(x)OK...I have not been able to resist and I looked at the solution:def fact(x):    if x == 0:        return 1    return x * fact(x - 1)x = input(int())print(x)Do you know any other valid way?What challenges/exercises/advices would you give to anyone willing to learn more and practice?

## Replies

 Simon Piras · October 8, 2014 Thanks! 0x13a _ · October 8, 2014 ``print("Hello user, give me a value!")x = int(input())f = xif x == 0:    print("1")elif (x < 0):    print("No that's impossible")else:    while x > 1:        f*=(x-1)        x = x - 1print(f)``It's very important that you leave tabs after if statements and also decremeting x
• 1

## Python

118,551 followers