Generation

generate functionThu, 15 Dec 2022

Create a function that outputs directory numbers (dictionary keys) by the selected value. directories = { '1': ['2207 876234', '11-2'], '2': ['10006'], '3': [] } For example: input = 2207 876234 output = 1 input = 11-2 output = 1 input = 10006 output = 2 input = 1434 output = 'Nothing found'

def search_goods(): global directories input_number = input('Input directory number: ') for key, value in directories.items(): for item in value: if input_number == item: return key return 'Nothing found'

Questions about programming?Chat with your personal AI assistant