Question: plz help my functions are’nt working (python)
Repl link:
https://replit.com/@BackgroundCodes/coding-exam-1#main.py
Repl code(copy the code into a blank repl to see):
# DICE ROLLING SIMULATOR (2 DICE) + game
# global varibles
dice1=0
dice2=0
chaching=10
# import librarys
import turtle
import random
# t.turtle
t = turtle.Turtle
dice1numresult = input("type go in console to create a number using 2 numbers from a dice and show you the total of the numbers on the dice")
# function to actually roll the dice
if dice1numresult == "go":
dice1 = random.randint(1,7)
dice2 = random.randint(1,7)
function1()
t.rt(180)
t.fd(50)
t.rt(180)
function2()
t.rt(180)
t.fd(50)
t.rt(180)
function3()
fungame = input("would you like to play a game? (type y for yes and n for no)")
# fungame
if fungame == "y":
dice1numresult != "go"
fundice1 = random.randint(1,7)
fundice2 = random.randint(1,7)
fundicetotal = fundice1 + fundice2
userguess = int(input("I have randomly generated a number from 1-12 and your job is to guess that number, if you guess it you get 10 chachign which is the in-game currency and the goal of the game is to collect as much of it as possible however if you guess wrong i take away 1 chaching but as a bonus since i am nice you start with 10 chaching, if you want to check you chaching just make a new line and type in the console /chaching. when you want to guess enter your guess here"))
if userguess != fundicetotal:
tryagain = input("uh oh - looks like you got that wrong, would you like to try again (y/n)")
if tryagain == "y":
fundice1 = random.randint(1,7)
fundice2 = random.randint(1,7)
fundicetotal = fundice1 + fundice2
userguess = int(input("I have randomly generated a number from 1-12 and your job is to guess that number, if you guess it you get 10 chachign which is the in-game currency and the goal of the game is to collect as much of it as possible however if you guess wrong i take away 1 chaching but as a bonus since i am nice you start with 10 chaching, if you want to check you chaching just make a new line and type in the console /chaching. when you want to guess enter your guess here"))
chaching = chaching - 1
if tryagain == "n":
fungame == "n"
dice1numresult == "go"
chaching = chaching - 1
if userguess == fundicetotal:
tryagaincorrect = input("uhhh - looks like you got that right, would you like to try again (y/n)")
if tryagaincorrect == "y":
fundice1 = random.randint(1,7)
fundice2 = random.randint(1,7)
fundicetotal = fundice1 + fundice2
userguess = int(input("I have randomly generated a number from 1-12 and your job is to guess that number, if you guess it you get 10 chachign which is the in-game currency and the goal of the game is to collect as much of it as possible however if you guess wrong i take away 1 chaching but as a bonus since i am nice you start with 10 chaching, if you want to check you chaching just make a new line and type in the console /chaching. when you want to guess enter your guess here"))
chaching = chaching + 10
if tryagaincorrect == "n":
fungame == "n"
dice1numresult == "go"
chaching = chaching + 10
if fungame == "n":
dice1numresult == "go"
chaching = chaching
checkchaching = input("would you like to check your balance of chaching (y/n)")
if checkchaching == "y":
print("your chaching amounts to ", chaching)
dice1numresult == "go"
if checkchaching == "n":
dice1numresult == "go"
# functions defines
def function1():
if dice1 == 1:
t.write("the dice rolled 1")
if dice1 == 2:
t.write("the dice rolled 2")
if dice1 == 3:
t.write("the dice rolled 3")
if dice1 == 4:
t.write("the dice rolled 4")
if dice1 == 5:
t.write("the dice rolled 5")
if dice1 == 6:
t.write("the dice rolled 6")
def function2():
if dice2 == 1:
t.write("the 2nd dice rolled 1")
if dice2 == 2:
t.write("the 2nd dice rolled 2")
if dice2 == 3:
t.write("the 2nd dic e rolled 3")
if dice2 == 4:
t.write("the 2nd dice rolled 4")
if dice2 == 5:
t.write("the 2nd dice rolled 5")
if dice2 == 6:
t.write("the 2nd dice rolled 6")
def function3():
total_of_dice = dice1 + dice2
t.write(total_of_dice)
# end of code