Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to get the index of a character from a string
Hi, i used this code it is getting the index value but i need it to get the index value as the expected output
s = 'Apples are totally awesome'
l = []
for idx, item in enumerate(s.lower()):
if 'a' in item:
if('l' in item) and ('a' in s[idx-1]):

Actual output:

Expected output:
buran wrote Dec-03-2019, 12:51 PM:
Please, use proper tags when post code, traceback, output, etc. This time I have added tags for you.
See BBcode help for more info.
can you explain the desired output in plain english
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs


Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  SyntaxError: unexpected character after line continuation character siteshkumar 2 239 Jul-13-2020, 07:05 PM
Last Post: snippsat
  String index out of bounds ( Python : Dict ) kommu 2 351 Jun-25-2020, 08:52 PM
Last Post: menator01
  Remove from end of string up to and including some character lbtdne 2 391 May-17-2020, 09:24 AM
Last Post: menator01
  String index out of range - help please DudleyDiccle 7 548 Mar-27-2020, 12:10 AM
Last Post: DudleyDiccle
  how can i handle "expected a character " type error , when I input no character vivekagrey 2 485 Jan-05-2020, 11:50 AM
Last Post: vivekagrey
  Unicode string index problem luoheng 6 550 Nov-23-2019, 03:04 PM
Last Post: luoheng
  python gives wrong string length and wrong character thienson30 2 564 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  IndexError: string index out of range ? Q_Y 5 1,748 Jul-05-2019, 07:18 PM
Last Post: noisefloor
  Find string and add character - newbi PyDK 1 469 May-15-2019, 01:22 PM
Last Post: ichabod801
  remove string character from url jacklee26 10 1,766 Mar-25-2019, 03:56 PM
Last Post: Larz60+

Forum Jump:

Users browsing this thread: 1 Guest(s)