Итак, вот моя проблема. Я создаю телефонный каталог в python 3.3.2, и мне нужно знать, как вызвать отдельные функции. Вот мой код:Как вызвать функцию?
details = {"Toby": "123", "James": "234", "Paul": "345"}
print("Welcome To The Telephone Directory.\n")
print("To search out specific details, please type Search.\n To add a new person to the Directory, type Add.\n To change someone's details, please type Edit.")
search = input();
if(input() == search.strip() in "search Search SEARCH".split()):
def search():
print("Please enter the name of the customer.")
customer = input()
print("Number:" ,details.get(customer))
if(customer not in details):
print("I'm sorry, but the person you defined is not in the directory.")
flag = True
while flag:
search()
flag = input("Would you like to look up another person? [Y/N]") == "y"
if(input() == add.strip() in "add Add ADD".split()):
def add():
print("Please enter the name of the new entry.")
name = input()
print("Now enter the entry's phone number.")
telNumber = input()
details[name] = telNumber
print("You have succesfully added a new entry:\n",name,"\n",telNumber)
Поэтому мне нужно знать, как вызвать функцию «Добавить» с самого начала.
Любые идеи?
Вы не можете назначить в выражении, поэтому 'if (input() == search.strip() в" search Search SEARCH ".split()):' is ** not ** делает то, что, по вашему мнению, делает. –
Вы вызываете функцию 'function_name (arguments)', но это не самая большая проблема с этим кодом на данный момент. –
Книга, которую вы читаете? –