I've created a function (izanamiPressureLevel_1
) that makes a random list (pressure
) following a certain set of rules. I'm trying to make while
loop that iterates until it returns a list of a specified length, but it always loops printing suitable lists indefinitely until I get an error. Can someone explain to me why or offer a solution? I tried to include a minimal example, but I'm not sure if its too long.
This is the error I'm getting.
[Previous line repeated 993 more times]
File "D:\Folu\Documents\code\PythonScripts\Getting_Started.py", line 14, in izanamiPressureLevel_1
pressure.append(random.choice(reset))
File "C:\Users\ridor\AppData\Local\Programs\Python\Python310\lib\random.py", line 378, in choice
return seq[self._randbelow(len(seq))]
File "C:\Users\ridor\AppData\Local\Programs\Python\Python310\lib\random.py", line 245, in _randbelow_with_getrandbits
k = n.bit_length() # don't use (n-1) here because n can be 1
RecursionError: maximum recursion depth exceeded while calling a Python object
Code:
import random
pressure = []
kuzushi = ["6B","6C(2),214A","6C(2),214B(GIMMICK)","CT"]
sixB = ["63214C","214214C","Throw", "Fuzzy7.j5b","CT","6B","2A"]
def izanamiPressureLevel_1():
twoA = ["2A,2B,5B,5C,214A","2A,2B,5B,5C,2CC","2A,2B,5B,5C"]
reset = ["63214C","ZA WAARUDO","2A"]
pressure = ["2A,2B,5B,5C,2CC"]
while pressure[-1] == "2A,2B,5B,5C,2CC":
if pressure[-1] == "2A,2B,5B,5C,2CC":
pressure.append(random.choice(reset))
if "2A" in pressure:
pressure.remove("2A")
pressure.append(random.choice(twoA))
if "2A,2B,5B,5C" in pressure:
pressure.append(random.choice(kuzushi))
if "6B" in pressure:
pressure.append("xxRCxx")
pressure.append(random.choice(sixB))
while pressure[-1] == "2A":
if pressure[-1] == "2A,2B,5B,5C,2CC":
pressure.append(random.choice(reset))
if "2A" in pressure:
pressure.remove("2A")
pressure.append(random.choice(twoA))
if "2A,2B,5B,5C" in pressure:
pressure.append(random.choice(kuzushi))
if "6B" in pressure:
pressure.append("xxRCxx")
pressure.append(random.choice(sixB))
while len(pressure) != 5:
izanamiPressureLevel_1()
print (pressure)
izanamiPressureLevel_1()