• Register
1 vote
50 views

Problem:

I am newbee in python programming and I have been instructed by my course teacher to do some programming practice. So, I wrote a code:

def random():
a = random.randint (0, x+1)

b = random.randint (0, y+1) 

c = random.randint (0, z+1) 

outer_function(a,b,c)

if outer_function(a,b,c) is True:
Break

if outer_function(a,b,c) is False:
random()

but when I run this code it gives me following error:

RuntimeError: maximum recursion depth exceeded while calling a Python object
IndentationError: expected an indented block
10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

1 vote
 
Best answer

Answer:

In your program tou are using randint function without importing it.

So you should import it by:

Import random

or

from random import randint

So your code should be like:

import random

def random():

  a = random.randint (0, x+1)

  b = random.randint (0, y+1) 

  c = random.randint (0, z+1) 

outer_function(a,b,c)

if outer_function(a,b,c) is True:
    break

  if outer_function(a,b,c) is False: 
    random()

 

or

from random import randint

def random():

  a = random.randint (0, x+1)

  b = random.randint (0, y+1) 

  c = random.randint (0, z+1) 

outer_function(a,b,c)

if outer_function(a,b,c) is True:
    break

  if outer_function(a,b,c) is False: 
    random()

Hope you understand this.

Happy coding. 

11 6 4
34,950 points

Related questions

0 votes
1 answer 57 views
57 views
Problem: Let me start off by saying that I am COMPLETELY new to programming. I have just recently picked up Python and it has consistently kicked me in the head with one recurring error -- "expected an indented block" Now, I know there are several other ... indentation has not given me better results. I have replaced all of my indents with 4 spaces and even rewritten the code several times.
asked Jan 10 Mashhoodch 13k points
0 votes
1 answer 25 views
25 views
Problem: Hello kodlogs, I am new to python language basically this is the first language I am learning as friend say is the easy language, and so wanted to learn more about it, but I am doing a simple for loop program and i am getting a error for this code below is the ... print(x) O Error: File "main.py", line 7 print(x) ^ IndentationError: expected an indented block I don't know what is error.
asked Jun 24, 2020 Gavin 15.3k points
1 vote
1 answer 4 views
4 views
Problem: How can I deal with this problem : python indentationerror expected an indented block
asked Mar 20 MUHAMMAD MUNEEB 83k points
0 votes
1 answer 4 views
4 views
Problem: When I compile the Python code below, I get > Indentationerror unindent does not match any outer indentation level
asked 5 days ago ochena 23.3k points
0 votes
1 answer 5 views
5 views
Problem: Please help me to solve it .. Indentationerror: unindent does not match any outer indentation level python
asked Apr 3 Ifra 36.4k points
1 vote
1 answer 47 views
47 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 73 views
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))
asked Mar 18, 2020 LizzyM 6.1k 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 13 views
13 views
Problem: Please let me know any solution regarding this .. while using python idle, by how many space are the code suites indented?
asked Apr 18 Ifra 36.4k points
0 votes
1 answer 3 views
3 views
Problem: I'm trying to figure out a solution, need help >Inconsistent use of tabs and spaces in indentation notepad++.
asked 7 hours ago Rada Gracelynn 1.8k points