• Register
0 votes
37 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,050 points

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,930 points

Related questions

0 votes
1 answer 44 views
44 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 jwilliam 3.9k points
0 votes
3 answers 482 views
482 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 1.2K views
1.2K views
Problem : I had to remove a +CompatEnvVars from following : SSLOptions +FakeBasicAuth +ExportCertData +CompatEnvVars +StrictRequire As it said it was an invalid command or something. So having removed that and following a instructions to a nail it get below error: ... maximum permissible length. (Error code: ssl_error_rx_record_too_long) I am very new to SSL, any advice on what is going wrong?
asked Jan 17 jwilliam 3.9k points
0 votes
2 answers 934 views
934 views
Problem : I am new to Py 3.5. This code was working properly in Python 2.7: with open(fname, 'rb') as f: lines = [x.strip() for x in f.readlines()] for line in lines: tmp = line.strip().lower() if 'some-pattern' in tmp: continue # ... code After upgrading to 3.5, I'm getting the: TypeError: a bytes-like object is required, not 'str'
asked Oct 22, 2019 peterlaw 6.9k points
1 vote
1 answer 90 views
90 views
Problem: I am trying to print some string in my python program but for some reason, it’s not working. The compiler says python syntaxerror: EOL while scanning string literal that is totally beyond my understandings. For obvious reason, I am avoiding my original code and ... test string" print(mystr) printStr() Here is the dummy code snippet. Please pull me up from the problem. Thanks to all.
asked Apr 7 Gavin 15.3k points