Problem!


#1

Hi,
what is the problem with following code as I am receiving NameError: name 'menu' is not defined?

class student:
        
    
    def v(self):
        self.x=input("enter name:")
        self.y=int(input("enter #:"))
        self.y=int(input("stnumber:"))
        
        
    def menu():
        print()
        print("1.add")
        print("2.max")
    
    
st=[]
st1=student()
while True:
    c=menu()
    if c==1:
        st1.v()
        st.append(st1)

#2

menu is not a global method. It is defined through the object st1. You need to use the dot operator to access it.


#3

Can you please take short example for me? I cannot understand your saying.


#4

If you need to access properties/methods, you use the dot operator. Thus, you'd need to do st1.menu() instead of menu()