Python: how to use list as source of selection for user input?
问题 Can anyone check this code and let me know what is wrong? input_list = ["One", "Two", "Three"] P1 = input("Select the input: ", input_list[0], input_list[1], input_list[2]) print (P1) 回答1: With python's raw_input it is not possible to give a preselected list to the user to choose from. With raw_input we collect raw strings. update : a nice solution is to use the new pick library: https://github.com/wong2/pick It provides a small curses interface to pick our choice from a given list. Get it