Uncategorized

When calling a function from a python module in my main script it causes the program to just end. Why is this happening and how to fix?


In my main script I have an outer function with an inner function containing an if, elif, and else condition. I won’t explain the entire program here yet. Anyways when the user input is “1” it should execute the main function of module 1 but its not doing it.

I am suspecting that it has something to do with this code block I have at the bottom of module 1, which I also have in bottom of my main script. How do I add the functionality of it being callable in my main script while retaining the ability to still be ran alone with the command line argument name input? Another problem I haven’t figured out is how to keep the command line argument name input from main script to transfer to module 1, and back the main script as I navigate?
if name == “main“:
import argparse

parser = argparse.ArgumentParser(
    description="Provides a personalized RPS game experience."
)

parser.add_argument(
    "-n", "--name", metavar="name",
    required=True, help="The name of the person playing the game."
)

args = parser.parse_args()

rock_paper_scissors = rps(args.name)
rock_paper_scissors()

ChatGPT is not helpful in fixing my program.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *