• Register
0 votes
73 views

PROBLEM:

Python programming is new to me . I wrote a code which gives me following error:

python indentationerror: unindent does not match any outer indentation level

 The code I wrote is:

import sys

def Function(x):
    result = 1
    for i in range (1,x):
        result = result * i * i
    print ("Your factorial is ",result)
    return result

print (Function(10))

 

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

1 vote
 
Best answer

Solution:

 

In your programm your logic is not right. Your logic should be like:

result = result * i

So your code should be like:

import sys

def Function(x):
    result = 1
    for i in range (1,x):
        result = result * i 
    print ("Your factorial is ",result)
    return result

print (Function(10))

And your output will be:

Your factorial is  362880
362880

Happy Coding.

11 6 4
34,950 points

Related questions

0 votes
1 answer 11 views
11 views
Problem: Please help me to solve it .. Indentationerror: unindent does not match any outer indentation level python
asked Apr 3 Ifra 37.2k points
0 votes
1 answer 194 views
194 views
Problem : When I try to compile my Python code below, I get below error “IndentationError: unindent does not match any outer indentation level” import sys def Factorial(n): # Return the factorial     myresult = 1     for j in range (1,n):         myresult = myresult * j     print "The factorial is: ",myresult     return myresult Why am I getting above error?
asked Jan 22, 2020 jwilliam 3.9k points
0 votes
1 answer 5 views
5 views
Problem: When I compile the Python code below, I get > Indentationerror unindent does not match any outer indentation level
asked May 3 ochena 23.3k points
1 vote
1 answer 48 views
48 views
Problem: For my project I wrote this code: def create_train_data(): trainday_data = [1100] for img in tqdm(os.listdir(TRAIN_DIR)): label = label_img(img) path = os.path.join(TRAIN_DIR, img) training_data.append([np.array(img), np.array(label)]) ... np.save('train_data.npy', training_data) ^ IndentationError: unindent does not match any outer indentation level Please help me to fix this poblem.
asked Apr 7, 2020 LizzyM 6.1k points
0 votes
1 answer 4 views
4 views
Problem: I'm trying to figure out a solution, need help >Unindent does not match any outer indentation level python.
asked 3 days ago Florina Gulnar 6.7k points
0 votes
1 answer 51 views
51 views
Problem: When I compile the Python code below, I get IndentationError: unindent does not match any outer indentation level import sys def Factorial(n): # Return factorial result = 1 for i in range (1,n): result = result * i print "factorial is ",result return result Why?
asked Jan 6 Mashhoodch 13k points
0 votes
1 answer 128 views
128 views
Problem : When I compile the Python code I get below error IndentationError: unindent does not match any outer indentation level
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
1 answer 6 views
6 views
Problem: When I compile the Python code below, I get IndentationError: unindent does not match any outer indentation level Thanks
asked Mar 16 ummesalma 29.2k points
0 votes
1 answer 29 views
29 views
Problem: I'm trying to create an application in Python 3.2 and I use tabs all the time for indentation, but even the editor changes some of them into spaces and then print out "inconsistent use of tabs and spaces in indentation" when I try to run the program. How can I change ... would be glad if I could get some overall tips on my code, if I have done a lot of mistakes I would be happy to hear.
asked Jan 26 Mashhoodch 13k points
0 votes
1 answer 42 views
42 views
Problem: I'm trying to create an application in Python 3.2 and I use tabs all the time for indentation, but even the editor changes some of them into spaces and then print out "inconsistent use of tabs and spaces in indentation" when I try to run the program
asked Jan 9 Mashhoodch 13k points