Page 28 - Python Cơ Bản
P. 28

QϲRK  Gɹ XLВ HɽRK TLš˜RK XLиG  list.index(obj)   2ЎY


          XɳQ XLϴ] WЌ XVϲ ZА MRHI\ GжE TL϶R Xм ч϶Y XMɱR XɳQ XLϴ]  2ЎY


          OLɺRK XɳQ XLϴ] WЌ UYʆRK )\GITXMSR  :ɴ Hд





           aList = [123, 'xyz', 'zara', 'abc'];




           print "Index for xyz : ", aList.index('xyz')

           print "Index for zara : ", aList.index('zara')






          /LM GLϰ] WЌ LMВR XLК OЎX UYϲ





           Index for xyz :  1


           Index for zara :  2





                 ɇϲS RKšвG KMɨ XVК GжE QϲRK





          ɇВ чϲS RKšвG XLи Xр GɨG KMɨ XVК GжE QШX QϲRK  Wм HдRK

          TLš˜RK XLиG  list.reverse()   4Lš˜RK XLиG Rɧ] OLɺRK XVϲ


          ZА OЎX UYϲ Qɧ XLE] чФM XVрG XMЎT QϲRK  list   :ɴ Hд
   23   24   25   26   27   28   29   30   31   32   33