New to learning Python and trying to test a few things out to better understand a better way to code within Python. For this question what I'm trying to do is, have the user input an answer from a list of options to then move onto the next function. So e.g.,
dnd_weapons = ["club", "great axe", "longbow", "hand crossbow"]
user_weapon = input("What weapon would you like to select? ", dnd_weapons)
The input I would like the user to see is:
What weapon would you like to select? club, great axe, longbow, hand crossbow
Currently I'm running into errors of getting this to work like the above code does not work. Hopefully this makes sense, just trying to find a better way to do an input from a list instead of re-writing the dnd_weapons over and over again in different sections of code.
Thank you in advance!!
inputmakes a string. So usesplitto separate it into parts based on a delimiter. In this case your delimiter is,(comma and space between each weapon)