#!/usr/bin/python3 import new_module import sys print("""Welcome to my Classes Python program! Do you want, to (C)ontinue gmae or (Q)uit game? Press "1" or "2""") answer = input("> ") class MainProgram (): if answer == "1": print("What do you want to do?") print("1. Do you want to Win the game, press (1)") print("2. Do you want to Lose the game, press (2)") answer_2 = input("> ") if answer_2 == "1": print("You pressed (1)") # You Lost, go to function print("You win") elif answer_2 == "2": print("you pressed 2") # Won Game print("You lost") else: print(f"Wrong selection, {answer_2}") print("Error!") the_count = [5, 4, 3, 2, 1] for i in the_count: print(f"And you lose in...: {i}") elif answer == "2": print ("you pressed (2)") print ("You lose") else: print(f"Wrong selection, {answer}") print("Error!") class Lost_Game(): def print_function (name): print(f"You {name}") sys.exit() class Win_Game(): def win_function (name): print(f"You {name}") sys.exit() var_2 = Lost_Game.print_function('lost') var = You_Won.identify('won')Please, could someone come up with a solution to this code so it works, for the last two classes Lost_Game() and Win_Game() classes and var and var_2 only print one line per correct each if statement above. Or explain how a Inheritance object works, thanks. Very new to Python classes.
please help with classes and return values
Messages In This Thread |
please help with classes and return values - by jamie_01 - Jan-14-2022, 03:51 AM
RE: please help with classes and return values - by menator01 - Jan-14-2022, 07:53 AM
RE: please help with classes and return values - by Gribouillis - Jan-14-2022, 07:53 AM
RE: please help with classes and return values - by jamie_01 - Jan-17-2022, 12:25 AM
RE: please help with classes and return values - by BashBedlam - Jan-17-2022, 01:09 AM
RE: please help with classes and return values - by menator01 - Jan-17-2022, 02:11 AM
|
Users browsing this thread: 1 Guest(s)