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

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Unicode string index problem luoheng 6 156 Nov-23-2019, 03:04 PM
Last Post: luoheng
  python gives wrong string length and wrong character thienson30 2 179 Oct-15-2019, 08:54 PM
Last Post: Gribouillis
  IndexError: string index out of range ? Q_Y 5 892 Jul-05-2019, 07:18 PM
Last Post: noisefloor
  Find string and add character - newbi PyDK 1 230 May-15-2019, 01:22 PM
Last Post: ichabod801
  remove string character from url jacklee26 10 1,049 Mar-25-2019, 03:56 PM
Last Post: Larz60+
  Replace changing string including uppercase character with lowercase character silfer 11 865 Mar-25-2019, 12:54 PM
Last Post: silfer
  Changing a character in a string Livne_ye 4 424 Mar-13-2019, 12:39 PM
Last Post: Larz60+
  How Do I find Index of a character in string? ilcaa72 5 853 May-23-2018, 11:44 PM
Last Post: wavic
  testing if a character in a string is an intended one Skaperen 2 723 Feb-27-2018, 02:51 AM
Last Post: Skaperen
  find a character in a string in python3 tony1812 6 2,718 Sep-27-2017, 03:28 PM
Last Post: nilamo

Forum Jump:

Users browsing this thread: 1 Guest(s)