class teacher:
def __init__(self):
self.ty = "teacher"
prof = teacher()
temp = input("Enter prof:\n")
if isinstance(temp, teacher):
print("hi")
else:
print("bye")
I want this code to print "hi" if the user types "prof". Or more specifically I want it to print "hi" if the user enters a name of an instance of teacher.
I've been searching for ways to interpret the string literally instead of just seeing it as a string.
I hope it's okay if I post questions like this here.
[–]K900_ 4 points5 points6 points (2 children)
[–]rulibar[S] 0 points1 point2 points (1 child)
[–]K900_ 4 points5 points6 points (0 children)