class and object class Person: def __init__ ( self , name , age): self .name = name self .age = age def myfunc ( self ): print ( "Hello my name is " + self .name) p1 = Person( "John" , 36 ) p1.myfunc()
Posts
Showing posts from April, 2022
- Get link
- X
- Other Apps
CHECKING IF ELEMENTS EXIST IN LISTđź‘Ź test_list = [ 1 , 6 , 3 , 5 , 3 , 4 ] print ( "Checking if 4 exists in list ( using loop ) : " ) for i in test_list : if ( i == 4 ) : print ( "Element Exists" ) print ( "Checking if 4 exists in list ( using in ) : " ) USING IN if ( 4 in test_list ): print ( "Element Exists" )