0

What is different between this Two Codes?

def get_Input(): Command = input(": ").split() verb_word = Command[0] if verb_word in verb_Dic: verb = verb_Dic[verb_word] else: print("Unknow Verb {}".format(verb_word)) return if len(Command) >= 2: noun_word = Command[1] print_Input(noun_word) else: print_Input("Nothing") def print_Input(noun): print("You said {}".format(noun)) return verb_Dic = {"say" : say} while True: get_Input() I changed this EX, But It doesn't work. So, I Changed again Like This.. def get_Input(): Command = input(": ").split() verb_word = Command[0] if verb_word in verb_Dic: verb = verb_Dic[verb_word] else: print("Unknow Verb {}".format(verb_word)) return if len(Command) >= 2: noun_word = Command[1] verb(noun_word) else: verb("Nothing") def say(noun): print("You said {}".format(noun)) return verb_Dic = {"say" : say} while True: get_Input() and FINALLY it works. But I can't Understand what is different between that. need someone help..

7th Aug 2019, 3:24 PM
Seung Ki Kim
Seung Ki Kim - avatar
3 Answers
+ 4
Print_input was not def in first code
7th Aug 2019, 3:31 PM
karangreat
karangreat - avatar
0
um..sorry, but Could you Please more explain about it..? What is that mean "was not def in first code"..? def print_Input(noun): is NOT a FUNCTION..? Or do you mean something else? :( P.S anyway, Thanks for your Answer!
7th Aug 2019, 3:41 PM
Seung Ki Kim
Seung Ki Kim - avatar