I've recently started to code and wanted to try my luck on a beginners program after 10 hrs of Udemy courses.
I've coded a "Guess the number" minigame, where a number is generated between 1-10 and I want the program to restart if someone guesses wrong.
import random
import os
import sys
def restart_program():
python = sys.executable
os.execv(sys.executable, ['python'] + sys.argv)
number = str(random.randrange(1,10))
choice = input("Which number did the PC pick?\n")
if choice == number:
print("You won!")
restart_program()
elif choice != number:
print("You lose!")
restart_program()
For some reason JupyterLab' kernel keeps dying on me the second I input a number.
I've tried restructuring the code and using completely different code but I always kill the kernel.
Can someone tell me if I did smth wrong?