0

This code always gives an error 'examine not defined', I don't know why

def get_input(): command=input('3nter phrase : ').split() verb_word=command[0] if verb_word in verb_dict: verb=verb_dict[verb_word] else: print(f'Unknown verb ({verb_word})') return if len(command) >= 2: noun_word=command[1] print(verb(noun_word)) else: print(verb('Nothing')) def say(noun): return f'You said {noun}' verb_dict={ 'say' : say, 'examine' : examine, } while True: get_input() class GameObject: class_name = '' desc = '' objects = {} def __init__(self,name): self.name=name GameObject.objects[self.class_name]=self def get_desc(self): return self.class_name + '\n' + self.desc class Goblin(GameObject): class_name = 'goblin' desc = 'a foul creature' goblin=Goblin('gobbly') def examine(noun): if noun in GameObject.objects: return GameObject.objects[noun].get_desc() else: print(f'There is no {noun} here')

11th Aug 2020, 4:42 PM
Ibrahim Phenom
5 Answers
+ 2
Please post this on code playground and link the code here.
11th Aug 2020, 4:48 PM
Sandra Meyer
Sandra Meyer - avatar
+ 2
Btw. it's easy to see, you use "examine" without signing any value to it before.
11th Aug 2020, 4:50 PM
Sandra Meyer
Sandra Meyer - avatar
11th Aug 2020, 4:50 PM
The future is now thanks to science
The future is now thanks to science - avatar
+ 1
you didn't make the examine function before calling it in the dictionary
11th Aug 2020, 4:47 PM
Randomocity
Randomocity - avatar
0
what are you trying to do in this code, please explain about it, so it will be easy to trace output.
11th Aug 2020, 5:20 PM
Ganesh Lokhande
Ganesh Lokhande - avatar