Dennis Lee Bieber wrote: >On Thu, 02 Jun 2005 16:12:44 +0900, Mark Sargent ><[EMAIL PROTECTED]> declaimed the following in >comp.lang.python: > > > >>How do I get that x to be an integer b4 it is entered into the indice.? >>Cheers. >> >> >> > If you really want the index, ask for the index... > > > >>>>hc >>>> >>>> >['Cat', 'roof', 'on', 'a', 'hot', 'tin'] > > >>>>try: >>>> >>>> >... i = hc.index("roof") >... new_hc = hc[:i] + hc[i+1:] + [hc[i]] >... except ValueError: >... pass >... > > >>>>new_hc >>>> >>>> >['Cat', 'on', 'a', 'hot', 'tin', 'roof'] > > > Hi All,
ok, got the following for that. >>> hotcat = ['Cat', 'roof', 'on', 'a', 'hot', 'tin'] >>> i = hotcat.index("roof") >>> hotcat = hotcat[:1] + hotcat[i+1:] + [hotcat[1]] >>> except ValueError: File "<stdin>", line 1 except ValueError: ^ SyntaxError: invalid syntax Cheers. P.S. If it's not too much, could you explain this line.? hotcat[:1] + hotcat[i+1:] + [hotcat[1]] hotcat[:1] = Cat? hotcat[i+1:] = all after roof? what does [hotcat[1]] do.? Mark Sargent. -- http://mail.python.org/mailman/listinfo/python-list