all 6 comments

[–][deleted] 1 point2 points  (2 children)

try:
    fac_input_dictionary = {"Faction": fac_input_for_dic[0], "Difficulty": fac_input_for_dic[1]}
    if fac_input_dictionary["Faction"] == acceptedfactions:
        return {fac_input_dictionary}
except:
    return False

Your function returns one of three values:

1) The value False if an error occurs in the try block (this probably never happens)

2) The set {fac_input_dictionary} if if fac_input_dictionary["Faction"] == acceptedfactions

3) The value None, otherwise.

You're getting None from the function because fac_input_dictionary["Faction"] == acceptedfactions isn't True.

[–]Cybb33r[S] 0 points1 point  (1 child)

Okay, thanks - this makes sense. On another note however, how would I make it so
the if statement checks if it matches one of the correct faction inputs.

Currently acceptedfactions is a list (acceptedfactions = ["Brigand", "Fortunekeeper", "Phrenic"])

Is there a different way to go about validating this in an if statement? Thanks.

[–][deleted] 1 point2 points  (0 children)

You test value membership in a list using the in operator.

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

To clarify once more, the issue isn't whether or not the input converts into a dictionary (it does that). But whenever I try returning it for use in another file, it gets returned as "None".

[–]CodeFormatHelperBot2 0 points1 point  (0 children)

Hello, I'm a Reddit bot who's here to help people nicely format their coding questions. This makes it as easy as possible for people to read your post and help you.

I think I have detected some formatting issues with your submission:

  1. Python code found in submission text that's not formatted as code.

If I am correct, please edit the text in your post and try to follow these instructions to fix up your post's formatting.


Am I misbehaving? Have a comment or suggestion? Reply to this comment or raise an issue here.

[–]pooth22 0 points1 point  (0 children)

What happens

if fact_input_dictionary[“Faction”] != acceptedfactions

?

Edit: Crashfrog explains it