# I dont know what"s wrong with my code 🤔(python)

Question: plz help my functions are’nt working (python)

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
``````

Hello @BackgroundCodes! Please edit your post’s code to be formatted like this:

`````````python
```
``````

srry, im new to replit but i will try to do so

``````# 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

``````
1 Like

This is not a replit thing, almost every website that you go on for code help will want this. Discourse, discord, probably stack Overflow too

i’m sorry but I am not familiar with any of these websites

however thanks for helping anyway👍

I believe it should read `dice1numresult = "go" `

`== ` checks if something is equal to something else, and it doesn’t assign value.

1 Like

@Doomsdaybear when i type it in the replit main.py the error shows on line 18, 22, 26

1 Like

Then define `function1` at the top, before all this

``````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"
``````

I would recommend defining all your functions before you do the main calling of them.

It should look like this then:

``````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)

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"
``````
1 Like

thank you @Doomsdaybear, this will help a lot This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.