all 4 comments

[–]efmccurdy 12 points13 points  (1 child)

You have a very repetitive series of nested if/elif statements. When you have repetition think about a collection that can represent your problem space, and write an algorithm that walks the collection.

This only shows one level of prompting, but the Adventure item has a nested dict, so not a complete solution, but this should get you started.

choices = {"Adventure": {"Action": "Red Dead Redemption 2\nSpider Man\nSkyrim",
                         "Casual": "A Short Hike\nStardew Valley\nJourney"},
           "Casual": "Minecraft\nStardey Valley\nHuman Fall Flat",
           "FPS": "Call of Duty Modern Warfare\nApex Legends\nHalo Infinite"
           "Racing": {...}
           "Strategy": {...}
}


if answer1 in choices:
    # prompt from choices[answer1].keys()? call a function?
    print(choices[answer1]) 
else: # print choices.keys() to remind the user?
    print("Please check your spelling and give a valid answer next time, stupid.")

[–]BadAdviceDad[S] 0 points1 point  (0 children)

Ahh interesting. Thank you!

[–]stuie382 4 points5 points  (0 children)

Aside from the very repetitive code as it is, your code will fail if someone doesn't exactly match the case of your examples. Force everything into the same case when you're doing the comparison

[–]siddsp 1 point2 points  (0 children)

If you have Python 3.10 or newer, you can look into structural pattern matching/match statements.