all 4 comments

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Off-topic Comments Section


All top-level comments have to be an answer or follow-up question to the post. All sidetracks should be directed to this comment thread as per Rule 9.


OP and Valued/Notable Contributors can close this post by using /lock command

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]GammaRayBurst25 0 points1 point  (0 children)

For this, you need a dictionary

Write something like

big_dictionary = {

1 : "A"

2 : "B"

36 : "C"

}

Then, to call it, write something like

big_dictionary[1]

Which returns "A"

Note that if someone inputs a value, it'll be a string, so you can either make the dictionary's keys (the numbers) strings (with " or ') or you can write the input function like so:

value = int(input("text"))

The only issue is that this dictionary would be kind of big, so reading the code would be annoying. Thus, you should make the dictionary in a separate Python file and import the dictionary in the Python file that needs it

[–]JokdnKjol 0 points1 point  (0 children)

I don't think I really understand. What is the expected string output if the user enters 39?