Posts

Showing posts from June, 2022

search any element in Dictionary

      j = int ( input ( "Any element to find in dictionary " ))       d ={ 1 : 2 , 3 : 4 , 5 :{ 11 : 12 }, 7 : 8 } l = list ( d . values ()) k =[] for i in l :         if isinstance ( i , int ):                 k . append ( i )         if isinstance ( i , dict ):                 l = k . append ( list ( i . values ())[ 0 ])     if j in k :         print ( "It is present" )   else :         print ( "It is not present" )                

Identify the numbers within the string input

  ######print only number from given any string################ def extract_store_sort ( string ):     k =[]     for a in string :         if a .isalpha()== True :             k . append ( " " )         if a .isnumeric() == True or a == "." :             k . append ( a )             s = "" . join ( k )     k1 = s . split ()     lst = list ( map ( eval , k1 ))     print ( sorted ( lst )) string = "AC*wv12n/:#e123we2.45oin  (fwoi6n#a98nfwb+owi" extract_store_sort ( string )