I made this simulation as a discordpy cog, but the bot goes offline and the console is open and don't do anything if I write or quit it...
At an amount of 15000 the bot crashes, what can I do, why it crashs?
There are discord emojies, which are selected randomly and there are different chances with the numbers etc. I hope somebody can help me here!
#bot.command()
async def simulate(self, ctx, amount):
wnitro = 0
wkey = 0
wgold = 0
wred = 0
wblue = 0
wgreen = 0
wgrey = 0
for zaehler in range(1, int(amount)):
drehungen = randint(5, 20)
gone = randint(1, 1000)
gtwo = randint(1, 1000)
gthree = randint(1, 1000)
gfour = randint(1, 1000)
gfive = randint(1, 1000)
gsix = randint(1, 1000)
gseven = randint(1, 1000)
geight = randint(1, 1000)
gnine = randint(1, 1000)
randomitem = [gone, gtwo, gthree, gfour, gfive, gsix, gseven, geight, gnine]
slots = []
for item in range(len(randomitem)):
if randomitem[item] >= 950:
slots.append("<a:classic:802844186026049546>")
elif randomitem[item] >= 850:
slots.append("<a:geld:770235576539676682>")
elif randomitem[item] >= 800:
slots.append("<a:goldendia:802976550995755019>")
elif randomitem[item] >= 650:
slots.append("<a:darkbluedia:802976435500875836>")
elif randomitem[item] >= 500:
slots.append("<a:reddia:802873281841463296>")
elif randomitem[item] >= 300:
slots.append("<a:greendia:802875898353156138>")
else:
slots.append("<a:greydia:802977070627553311>")
cdrehung = 1
nitroextra = randint(1, 100)
keyextra = randint(1, 10)
coinsextra = randint(1, 5)
coins2extra = randint(1, 2)
i = 0
while i < drehungen:
if cdrehung == 0:
gewinn = slots[4]
elif cdrehung == 1:
gewinn = slots[5]
elif cdrehung == 2:
gewinn = slots[6]
elif cdrehung == 3:
gewinn = slots[7]
elif cdrehung == 4:
gewinn = slots[8]
elif cdrehung == 5:
gewinn = slots[0]
elif cdrehung == 6:
gewinn = slots[1]
elif cdrehung == 7:
gewinn = slots[2]
elif cdrehung == 8:
gewinn = slots[3]
cdrehung -= 9
cdrehung += 1
i += 1
if i == drehungen:
if gewinn == "<a:classic:802844186026049546>":
if nitroextra == 1:
wnitro += 1
else:
drehungen += 1
elif gewinn == "<a:geld:770235576539676682>":
if keyextra == 1:
wkey += 1
else:
drehungen += 1
elif gewinn == "<a:goldendia:802976550995755019>":
if coinsextra == 1:
wgold += 1
else:
drehungen += 1
elif gewinn == "<a:darkbluedia:802976435500875836>":
if coins2extra == 1:
wblue += 1
else:
drehungen += 1
elif gewinn == "<a:reddia:802873281841463296>":
wred += 1
elif gewinn == "<a:greendia:802875898353156138>":
wgreen += 1
elif gewinn == "<a:greydia:802977070627553311>":
wgrey += 1
await ctx.send(f"There are the results out of `{str(amount)}x` spins: {str(wnitro)}x Nitro, {str(wkey)} Key, {str(wgold)} <a:goldendia:802976550995755019>, {str(wblue)} <a:darkbluedia:802976435500875836>, {str(wred)} <a:reddia:802873281841463296>, {str(wgreen)}<a:greendia:802875898353156138>, {str(wgrey)}<a:greydia:802977070627553311>")
thanks to everyone who helps c:
Update: I take it back, theoretically your slots could all be the same thing, or a combination of things that cause drehungen to always implement. You really need to reconsider the logic on your loop.
Update: actually that is false, you do update cdrehung which updates gewinn... this is pretty convoluted, but it does seems like it should have to end at some point. That being said this loop is a bit complicated, I would consider some debug messages for all these different variables to figure out what is going on.
Just looking at it, inside your while loop the state of gewinn doesn't change, or any of the other items (wnitro wkey wgold wblue)... sooo if that is the case it could mean that drehungen is always being incremented... which means i == drehungen is always true... which means an infinite loop.
Related
I am attempting to create an exam grading program. I successfully wrote each function to do what I need it to, but when I attempt to execute the entire program, I am running into issues with my return variables not being referenced.
Here is my code for context:
def userinput():
allinputs = []
while True:
try:
results = list(map(int, input('Exam points and exercises completed: ').split(' ')))
allinputs.append(results)
except:
ValueError
break
return allinputs
def points(allinputs):
exampoints = []
exercises = []
exercises_converted = []
gradepoints = []
counter = 0
for i in allinputs:
exampoints.append(i[0])
exercises.append(i[1])
for e in exercises:
exercises_converted.append(e//10)
for p in exampoints:
p2 = exercises_converted[counter]
gradepoints.append(p + p2)
counter += 1
return (gradepoints, exampoints, exercises_converted)
def average(gradepoints):
avg_float = sum(gradepoints) / len(gradepoints)
points_avg = round(avg_float, 1)
return points_avg
def pass_percentage(exercises_converted, exampoints):
failexam = []
passexam = []
passorfail = []
i = 0
while i < len(exampoints):
if exampoints[i] < 10 or exercises_converted[i] + exampoints[i] < 15:
failexam.append("fail")
passorfail.append(0)
else:
passexam.append("pass")
passorfail.append(1)
i += 1
percentage_float = len(passexam)/len(failexam)
percentage = round(percentage_float, 1)
return (percentage, passorfail)
def grades_distribution(passorfail, gradepoints):
grades = []
i = 0
l = 5
while i < len(gradepoints):
if passorfail[i] == 0:
grades.append(0)
elif passorfail[i] != 0 and gradepoints[i] >= 15 and gradepoints[i] <= 17:
grades.append(1)
elif passorfail[i] != 0 and gradepoints[i] >= 18 and gradepoints[i] <= 20:
grades.append(2)
elif passorfail[i] != 0 and gradepoints[i] >= 21 and gradepoints[i] <= 23:
grades.append(3)
elif passorfail[i] != 0 and gradepoints[i] >= 24 and gradepoints[i] <= 27:
grades.append(4)
elif passorfail[i] != 0 and gradepoints[i] >= 28 and gradepoints[i] <= 30:
grades.append(5)
i += 1
while l >= 0:
print(l, ": ", "*" * grades.count(l))
return
userinput()
print("Statistics:")
points(allinputs)
print(f"Points average: {average(gradepoints)}")
print(f"Pass percentage: {pass_percentage(exercises_converted, exampoints)}")
print("Grade distribution")
grades_distribution(passorfail, gradepoints)
I have no problems with the mechanics within each function; rather, my error lies where I try calling each of them from the main function.
The user input() function runs fine, and returns allinputs. However, when the second function points(allinputs) is called, the program states that the argument is undefined.
You should store the return value of a function before passing it as argument.
This should solve your problem
allinputs = userinput()
points(allinputs)
The code below returns 'TypeError: 'int' object is not subscriptable' when move_pas is called. The thnig is, is that the code affecting this is also in move_ag, but when I call that there is no error and I cant figure out why that is. I'm running this in python3.9.2 in vscode if that matters. Thanks in advance. (sorry for bad english)
import random
char_list = []
stance_list = []
spot_list = []
status_list = []
amount_list = []
def remake_name_list():
global name_list
name_list = ["Josh", "Jeff", "Lisa", "Addie", "Jack", "John", "Zac", "Evan", "Brayden", "Seb", "Sab", "Nick", "Dom", "Rex", "James", "Robert",
"John", "Michael", "William", "David", "Richard", "Joseph", "Thomas", "Charles", "Christopher", "Daniel", "Matthew", "Anthoney", "Mark"]
remake_name_list()
def gen(amount):
for i in range(0, amount):
rand = random.choice(name_list)
char_list.append(rand)
name_list.remove(rand)
rand = random.randint(0, 8)
if rand == 8:
stance_list.append("aggressive")
elif rand != 8:
stance_list.append("passive")
rand = random.randint(0, amount*2)
spot_list.append(rand)
amount_list.append(2)
amount_list.append(2)
rand = random.randint(1, 2)
if rand == 1:
amount_list.append(2)
elif rand == 2:
pass
for i in range(0, max(spot_list)):
if spot_list.count(i) >= 3:
amount_list.clear()
gen(amount)
def move_ag(amount_list, stance_list):
if 'aggressive' in stance_list:
for i in range(0, len(char_list)):
if stance_list[i] == "aggressive":
am = spot_list.count(spot_list[i])
if am == 1:
stance_list[i] = 2
amount_list[spot_list[i]] -= 2
elif am == 2:
stance_list[i] = 1.5
amount_list[spot_list[i]] -= 1.5
def move_pas(amount_list, stance_list):
if 'passive' in stance_list:
for i in range(0, len(char_list)):
if stance_list[i] == "passive":
am = spot_list.count(spot_list[i])
if am == 1:
stance_list[i] = 2
amount_list[spot_list[i]] -= 2
elif am == 2:
if amount_list[i] == 1:
stance_list = 1
amount_list[spot_list[i]] -= 1
if amount_list[i] == 2:
stance_list = 1
amount_list[spot_list[i]] -= 1
if amount_list[i] == 0.5:
stance_list = 0.5
amount_list[spot_list[i]] -= 0.5
amount = 10
gen(amount)
move_ag(amount_list, stance_list)
move_pas(amount_list, stance_list)
print(stance_list)
print(amount_list)
The way that you have it:
def move_pas(amount_list, stance_list):
if 'passive' in stance_list:
for i in range(0, len(char_list)):
if stance_list[i] == "passive":
am = spot_list.count(spot_list[i])
if am == 1:
stance_list[i] = 2
amount_list[spot_list[i]] -= 2
elif am == 2:
if amount_list[i] == 1:
stance_list = 1 #------------------------- here
amount_list[spot_list[i]] -= 1
if amount_list[i] == 2:
stance_list = 1 #------------------------- here
amount_list[spot_list[i]] -= 1
if amount_list[i] == 0.5:
stance_list = 0.5 #----------------------- here
amount_list[spot_list[i]] -= 0.5
If any of the if statements is met the stance_list is changed to an integer (1 or 0.5). So the next time the loop goes on it will meet this statement if stance_list[i] == "passive" and will tell you that a integer cannot be subscripted (Which is to be expected).
I assume what you want to do is to change the i-th element of stance_list to that number. Like this:
def move_pas(amount_list, stance_list):
if 'passive' in stance_list:
for i in range(0, len(char_list)):
print(stance_list)
if stance_list[i] == "passive":
am = spot_list.count(spot_list[i])
if am == 1:
stance_list[i] = 2
amount_list[spot_list[i]] -= 2
elif am == 2:
if amount_list[i] == 1:
stance_list[i] = 1 #------------------------- here
amount_list[spot_list[i]] -= 1
if amount_list[i] == 2:
stance_list[i] = 1 #------------------------- here
amount_list[spot_list[i]] -= 1
if amount_list[i] == 0.5:
stance_list[i] = 0.5 #----------------------- here
amount_list[spot_list[i]] -= 0.5
im using this code to simulate choosing first player in a dice game
but it throws a maximum depth error from time to time
how can i fix it?
is the problem from the code or the language?
import random
u1 = random.randint(1, 6)
u2 = random.randint(1, 6)
u3 = random.randint(1, 6)
u4 = random.randint(1, 6)
users = [u1, u2, u3, u4]
roll_outcome = []
tie_outcome = []
def outcome():
if len(roll_outcome) == 1:
if roll_outcome[0] == 0:
print("u1 is P1")
elif roll_outcome[0] == 1:
print("u2 is P1")
elif roll_outcome[0] == 2:
print("u3 is P1")
elif roll_outcome[0] == 3:
print("u4 is P1")
else:
if tie_outcome != 0:
tie_outcome.clear()
elif len(roll_outcome) > 1:
for i in range(len(roll_outcome)):
if i == 0:
u10 = random.randint(1, 6)
tie_outcome.append(u1)
elif i == 1:
u20 = random.randint(1, 6)
tie_outcome.append(u20)
elif i == 2:
u30 = random.randint(1, 6)
tie_outcome.append(u3)
elif i == 3:
u40 = random.randint(1, 6)
tie_outcome.append(u4)
roll(tie_outcome)
def roll(enterying_data):
for i in range(len(enterying_data)):
if max(enterying_data) == enterying_data[i]:
roll_outcome.append(i)
outcome()
roll(users)
fillings:
...........................................
It's a little of both.
Your code uses recursive looping -- roll calls outcome which calls roll etc and this can happen an unbounded number of times. In some languages, you'd be able to get away with this via tail-call optimization performed by the compiler or interpreter. Python does not have this sort of optimization, so there's a limit to how deep your recursive calls can be in a Python program.
Luckily, it's not hard to make this loop iterative (which means it can loop an infinite number of times without requiring an infinitely deep stack).
def outcome():
if len(roll_outcome) == 1:
if roll_outcome[0] == 0:
print("u1 is P1")
elif roll_outcome[0] == 1:
print("u2 is P1")
elif roll_outcome[0] == 2:
print("u3 is P1")
elif roll_outcome[0] == 3:
print("u4 is P1")
return None # done!
else:
if tie_outcome != 0:
tie_outcome.clear()
elif len(roll_outcome) > 1:
for i in range(len(roll_outcome)):
if i == 0:
u10 = random.randint(1, 6)
tie_outcome.append(u1)
elif i == 1:
u20 = random.randint(1, 6)
tie_outcome.append(u20)
elif i == 2:
u30 = random.randint(1, 6)
tie_outcome.append(u3)
elif i == 3:
u40 = random.randint(1, 6)
tie_outcome.append(u4)
return tie_outcome # roll again
def roll(enterying_data):
for i in range(len(enterying_data)):
if max(enterying_data) == enterying_data[i]:
roll_outcome.append(i)
return outcome()
while users is not None:
users = roll(users)
Note that you still have an issue here where the logic for settling ties doesn't really work, so the code will just go into an infinite loop at that point, but you at least won't get the DepthError any more...
FWIW, if the point of this code is to randomly pick P1 from among the four users, you could do this much more simply with:
import random
print(f"u{random.randint(1, 4)} is P1")
I defined the function 'actualizar_contadores()' and when called inside the main() function, its supossed to update the values of all the variables that were defined at the beginning of the script. First I didnt pass the actual variables as parameters to the function but that resulted in a "local variable referenced before assignment" error. Then I passed the references as parameters and that problem was gone but when I wanted to see the results they werent updated. I tried returning a tuple and assigning it to the variables in order to update their values, but it isnt working either and I get the local variable referenced before assignment error again. What can I do?
cant_motos = cant_autos = cant_camiones = 0
recaudacion_total = recaudacion_efectivo = recaudacion_telepeaje = 0
pasadas_primera_hora = pasadas_segunda_hora = pasadas_tercera_hora = pasadas_cuarta_hora = 0
cont_efectivo = cont_telepeaje = 0
patente_actual = ""
patente_nueva = ""
def actualizar_contadores(vehiculo, forma_de_pago, cant_motos,
cant_autos, cant_camiones,recaudacion_efectivo,
recaudacion_telepeaje,cont_efectivo,cont_telepeaje):
if vehiculo == "Moto":
cant_motos += 1
if forma_de_pago == 1:
recaudacion_efectivo += 20
cont_efectivo += 1
elif forma_de_pago== 2:
recaudacion_telepeaje += 20
cont_telepeaje += 1
elif vehiculo == "Auto":
cant_autos += 1
if forma_de_pago == 1:
recaudacion_efectivo += 40
cont_efectivo += 1
elif forma_de_pago == 2:
recaudacion_telepeaje += 40
cont_telepeaje += 1
elif vehiculo == "Camion":
cant_camiones += 1
if forma_de_pago == 1:
recaudacion_efectivo += 80
cont_efectivo += 1
elif forma_de_pago == 2:
recaudacion_telepeaje += 80
cont_telepeaje += 1
def main():
# menu principal
opcion = pedir_opcion(menu_principal, 4)
while opcion != 4:
while opcion != 3:
if opcion == 1:
carga = pedir_opcion(menu_ingreso_datos, 2)
print("Ingrese la siguiente operacion: ")
opcion = pedir_opcion(menu_principal, 4)
elif opcion == 2:
if carga == 1:
diferencia = 0
tiempo_inicial = time.time()
while diferencia < 32:
contar_pasadas(diferencia, pasadas_primera_hora,
pasadas_segunda_hora,
pasadas_tercera_hora,
pasadas_cuarta_hora)
tipo_vehiculo = pedir_opcion(menu_vehiculos, 3)
if tipo_vehiculo == 1:
vehiculo = "Moto"
elif tipo_vehiculo == 2:
vehiculo = "Auto"
elif tipo_vehiculo == 3:
vehiculo = "Camion"
forma_de_pago = pedir_opcion(menu_forma_de_pago, 2)
if forma_de_pago == 2:
patente = pedir_patente()
patente_nueva = definir_patente_nueva(patente)
actualizar_contadores(vehiculo, forma_de_pago, cant_motos,
cant_autos, cant_camiones, cont_efectivo,
cont_telepeaje, recaudacion_efectivo,
recaudacion_telepeaje)
tiempo_final = time.time()
diferencia = tiempo_final - tiempo_inicial
elif carga == 2:
vehiculos = "Moto", "Auto", "Camion"
formas_de_pago = "Efectivo", "Telepeaje"
diferencia = 0
tiempo_inicial = time.time()
while diferencia < 4:
contar_pasadas(diferencia, pasadas_primera_hora,
pasadas_segunda_hora,
pasadas_tercera_hora,
pasadas_cuarta_hora)
vehiculo = random.choice(vehiculos)
forma_de_pago = random.choice(formas_de_pago)
aviso_pasada = "{}. Pago con {}. Hora de pasada: {}.".format(vehiculo,
forma_de_pago,
str((round(diferencia / 60) + 1)))
if forma_de_pago == "Telepeaje":
patente = generar_patente()
aviso_pasada += "Patente: {}".format(patente)
patente_nueva = definir_patente_nueva(patente)
print(aviso_pasada)
actualizar_contadores(vehiculo, forma_de_pago, cant_motos,
cant_autos, cant_camiones, cont_efectivo,
cont_telepeaje, recaudacion_efectivo,
recaudacion_telepeaje)
tiempo_final = time.time()
diferencia = tiempo_final - tiempo_inicial
time.sleep(random.randint(0,1))
pago_mayor_uso = forma_de_pago_mas_usada(cont_telepeaje, cont_efectivo)
promedio_pasadas_por_hora = round((cant_autos + cant_motos + cant_camiones) / 4, 2)
hora_pico = definir_hora_pico(pasadas_primera_hora,
pasadas_segunda_hora,
pasadas_tercera_hora,
pasadas_cuarta_hora)
recaudacion_total = recaudacion_efectivo + recaudacion_telepeaje
pases_totales = cant_motos + cant_autos + cant_camiones
print("Ingrese la siguiente operacion: ")
opcion = pedir_opcion(menu_principal, 4)
main()```
You should not pass global vars to functions by parameters. Use global keyword.
Here is an example:
x = 10
y = 20
def myFunc():
global x
x = 3
y = 2
myFunc()
print(x, y) # output: 3 20
Ok I have a feeling that this is a simple simple issue but I have been staring at this code for about 10 hours now.
The issue I am having is in mastermind is that once I get it to recognize that I have the correct colors in the right spot I can get it to display the right spots with X and the wrong spots with O. I need to be able to convert that so instead of X and O I need it to tell the user that he/she has 2 blacks and one white
For example: The secret code is RGYB The user enters RGOY so then Python relays "You have 2 blacks(The R and G spots) and one 1 White (The Y because it's the right color just in the wrong index) As of right now I got it to display X for the right color in the right spot and anything else it is an O
I will post what I have been working with now but today I am at my wit's end
https://pastebin.com/HKK0T7bQ
if correctColor != "XXXX":
for i in range(4):
if guess[i] == tempCode[i]:
correctColor += "X"
if guess[i] != tempCode[i] in tempCode:
correctColor += "O"
print (correctColor + "\n")
if correctColor == "XXXX":
if attempts == 1:
print ("You think you are sweet because you got it right on the first try? Play me again!")
else:
print ("Well done... You needed " + str(attempts) + " attempts to guess.")
game = False
A few comments
X and O
you use X and 0 to denote the success, it will be easier and faster to use a list or tuple or booleans for this, that way you can use sum() to count how many colors and locations were correct. Then whether you represent that with X and O or red and white pins is a matter for later
compartmentalization
Your game logic (guess input, input validation, do you want to continue, etc) is mixed with the comparison logic, so it would be best to separate the different functions of your program into different methods.
This is an fineexample to introduce object oriented programming, but is so simple it doesn't need OO, but it can help. What you need is a method which takes a series of colours and compares it to another series of colours
Standard library
Python has a very extended standard library, so a lot of stuff you want to do probably already exists
Correct colours
to count the number of letters which occur in 2 strings, you can use collections.Counter
guess = "RGOY "
solution = "RGYB"
a = collections.Counter(guess)
b = collections.Counter(solution)
a & b
Counter({'G': 1, 'R': 1, 'Y': 1})
correct_colours = sum((a & b).values())
3
So the user guessed 3 colours correctly
Correct locations
can be solved with an easy list comprehension
[g == s for g, s in zip(guess, solution)]
[True, True, False, False]
sum(g == s for g, s in zip(guess, solution))
2
so the used put 2 colours on the correct location
This is a MasterMind I made in Python. Hope you like it and it helped you! :)
import random
import time
from tkinter import *
def select_level():
global level
level = level_selector.get()
root.destroy()
root = Tk()
level_selector = Scale(root, from_=1, to=3, tickinterval=1)
level_selector.set(0)
level_selector.pack()
Button(root, text="Select a difficulty level", command=select_level).pack()
mainloop()
cpc_1_digit = 0
cpc_2_digit = 0
cpc_3_digit = 0
cpc_4_digit = 0
p_1_digit = 0
p_2_digit = 0
p_3_digit = 0
p_4_digit = 0
correct_correct = 0
correct_wrong = 0
chances = 0
if level == 1:
chances = 15
elif level == 2:
chances = 10
else:
chances = 7
cpc_1_digit = random.randint(0, 9)
while cpc_2_digit == cpc_1_digit or cpc_2_digit == cpc_3_digit or cpc_2_digit ==
cpc_4_digit:
cpc_2_digit = random.randint(0, 9)
while cpc_3_digit == cpc_1_digit or cpc_3_digit == cpc_2_digit or cpc_3_digit ==
cpc_4_digit:
cpc_3_digit = random.randint(0, 9)
while cpc_4_digit == cpc_1_digit or cpc_4_digit == cpc_2_digit or cpc_4_digit ==
cpc_3_digit:
cpc_4_digit = random.randint(0, 9)
while chances > 0:
correct_correct = 0
correct_wrong = 0
answer = input("Enter a four-digit number with different digits (e.g 1476): ")
p_1_digit = int(answer[0])
p_2_digit = int(answer[1])
p_3_digit = int(answer[2])
p_4_digit = int(answer[3])
if p_1_digit == cpc_1_digit:
correct_correct = int(correct_correct) + 1
elif p_1_digit == cpc_2_digit or p_1_digit == cpc_3_digit or p_1_digit ==
cpc_4_digit:
correct_wrong = int(correct_wrong) + 1
else:
pass
if p_2_digit == cpc_2_digit:
correct_correct = correct_correct + 1
elif p_2_digit == cpc_1_digit or p_2_digit == cpc_3_digit or p_2_digit ==
cpc_4_digit:
correct_wrong = int(correct_wrong) + 1
else:
pass
if p_3_digit == cpc_3_digit:
correct_correct = int(correct_correct) + 1
elif p_3_digit == cpc_1_digit or p_3_digit == cpc_2_digit or p_3_digit ==
cpc_4_digit:
correct_wrong = int(correct_wrong) + 1
else:
pass
if p_4_digit == cpc_4_digit:
correct_correct = int(correct_correct) + 1
elif p_4_digit == cpc_1_digit or p_4_digit == cpc_3_digit or p_4_digit ==
cpc_2_digit:
correct_wrong = int(correct_wrong) + 1
else:
pass
print("")
if int(correct_correct) == 4:
print("Congratsulations! You found the computer's number!")
break
elif int(correct_wrong) > 0 or int(correct_correct) >= 1 and int(correct_correct)
< 4:
print("You got " + str(correct_correct) + " correct digit(s) in the correct
place, and " + str(correct_wrong) + " correct digit(s) but in wrong place.")
elif int(correct_correct) == 0 and int(correct_wrong) == 0:
print("You didn't guess any number, try again!")
else:
raise Exception("CheckError: line 69, something went wrong with the
comparings.")
exit()
print("")
chances = chances - 1
if chances == 0:
print("You lost... The secret number was " + str(cpc_1_digit) + str(cpc_2_digit)
+ str(cpc_3_digit) + str(cpc_4_digit) + ". Try again by rerunning the program.")
time.sleep(4)