• Register
0 votes
64 views

Problem:

I am new to python programming and I am little bit bit confused about some things like 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()

which gives me following error:

RuntimeError: maximum recursion depth exceeded while calling a Python object
IndentationError: expected an indented block

I am confused about those things, why is this error shown to me ?

10 7 2
6,060 points

Please log in or register to answer this question.

1 Answer

0 votes

Answer:

In your program tou are using randint function but you did not import it .

So you should write something like:

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()

Happy coding

11 6 4
34,950 points

Related questions

0 votes
1 answer 55 views
55 views
Problem : I am trying to write my first program in Vpython and I have to make the simulation of mixing two gases. First I had the problem with borders, but now when my balls(that represents a gas particles) stay within a border there is the sth different wrong. ... ) for j in range(0,len(self.listOfBalls)): self.listOfBalls[j].pos=poruszanie(self.listOfBalls,self.listOfBalls[j].pos,self.numCell,0)
asked Jan 23, 2020 jwilliam 3.9k points
0 votes
3 answers 632 views
632 views
Problem : I am getting below error maximum recursion depth exceeded while calling a python object
asked Oct 21, 2019 peterlaw 6.9k points
0 votes
1 answer 8 views
8 views
maximum recursion depth exceeded while calling a python object
asked Feb 16 ArifulIslam 7.5k points
0 votes
1 answer 13 views
13 views
recursionerror: maximum recursion depth exceeded in comparison
asked Feb 16 ArifulIslam 7.5k points
0 votes
1 answer 12 views
12 views
Problem: How to I Solve this: runtimeerror maximum recursion depth exceeded in cmp HELP! I need help understanding this: runtimeerror maximum recursion depth exceeded in cmp Can someone please help solve this, I am new in python(). Someone have idea to solve this thanks!
asked Mar 7 Mashhoodch 13k points
0 votes
1 answer 1 view
1 view
Question: I have a Computer Science Midterm tomorrow and I need help determining the complexity of these recursive functions. I know how to solve simple cases, but I am still trying to learn how to solve these harder cases. These were just a few of the example problems that I could not figure out. Any ... printf("%d, %d\n",m, o); } else { recursiveFun4(n-1, m+1, o); recursiveFun4(n-1, m, o+1); }
asked 1 day ago Atik03 10.1k points
0 votes
1 answer 2 views
2 views
Question: I have a Computer Science Midterm tomorrow and I need help determining the complexity of these recursive functions. I know how to solve simple cases, but I am still trying to learn how to solve these harder cases. These were just a few of the example problems that I could not figure out. Any ... printf("%d, %d\n",m, o); } else { recursiveFun4(n-1, m+1, o); recursiveFun4(n-1, m, o+1); }
asked 5 days ago Atik03 10.1k points
0 votes
1 answer 8 views
8 views
Problem: How to solve: T(n) = T(n/2) + T(n/4) + T(n/8) + (n)
asked Mar 21 ummesalma 25.2k points
0 votes
1 answer 10 views
10 views
Problem: Does anyone know that how to search multidimensional array for key and return value?
asked Mar 12 Ifra 24.4k points
0 votes
1 answer 3 views
3 views
Problem: Hi there! I want to know that is there any way I can do the following in Python: def func1(): def func2(): And call this function from another function. Please guide. Thank You!
asked Mar 29 Code Learner 9.2k points