My code doesn't seem to run i get a error message but i don't see a problem maybe someone can

Joined
Jul 25, 2024
Messages
21
Reaction score
1
Code:
# This is a small text based adventure game
# Meant to test my python skills
# I will release this to the public if I decide it's good enough
# Starting date and time 2/5/2025 - 9:44 PM
class game():
    def __init__(self):
        self.player_info()
        self.cuss_checker()
        self.main()
    def player_info(player_age=10, player_name="Chris Jones"):
        player_name = input(cuss_checker(player_name))
        player_age = int(input(f"What is your age {player_name}?"))
        return {"age": player_age, "name": player_name}
    def cuss_checker(word):
        word = word.lower()
        cuss_words = ["various cusswords"]
        while word in cuss_words:
            print("Sorry that is not allowed")
            word = input("Please try again ")
            continue
        else:
            print("That is allowed thank you!")
            return word
    def main(player_age, player_name):
        game_running = True
        print("Welcome to a small text based adventure")
        while game_running:
            start_game = input("Would you like to play this game? (yes/no): ").lower()
            if start_game != "yes":
                print("Thank you for considering this game, have a nice day")
                game_running = False
                continue
            if player_age < 10:
                print(f"I am sorry {player_name}, you are not old enough to play this game please try again after your tenth birthday ")
                continue
            else:
                print(f"Welcome {player_name} to the game, let's get the story started!")
                
                play_again = input("Would you like to play again? (yes/no): ").lower()
                if play_again != "yes":
                    print("Thank you for playing this game, have a nice day")
                    game_running = False
                    continue
                else:
                    print("Thanks for playing my game, have a nice day")
                    game_running = False



game()
i edited out some of the code for obvious reasons but this is pretty much the same code
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,230
Messages
2,571,161
Members
47,796
Latest member
AlphonseNa

Latest Threads

Top