What can i do if u want to check the position of specific letter in a input of users ?(Python) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

What can i do if u want to check the position of specific letter in a input of users ?(Python)

Input : I am a little boy. Output: Output will show positions of "a". Note : I have needed Python solution..

15th Aug 2020, 6:59 AM
Shubham Ingale
Shubham Ingale - avatar
5 Answers
15th Aug 2020, 8:24 AM
Shubham Ingale
Shubham Ingale - avatar
15th Aug 2020, 7:16 AM
Shubham Ingale
Shubham Ingale - avatar
0
Look at: Conversion of string to list Index Loops
15th Aug 2020, 7:12 AM
Rüdiger Henze
Rüdiger Henze - avatar
0
text = input() for i in range(len(text)): if(text[i]=='a'): print(i,end=' ')
15th Aug 2020, 7:13 AM
Peter Parker
Peter Parker - avatar
0
Hey AnDyOs[SHUBHAM INGALE] You Having More Than 2 Options To Perform This Task First One Is To Run A Loop And Initialise A Variable Count Which Will Keep Counting The Position Of The Expected Character And Break When We Got It. And Else You Can Use Methods Of List By Spliting The String By Default Spaces And Then Perform index Method To Catch The First Occurrence Of The Expected Character. But In Second Option This Will Output You The First Occurrence Of The Character. Drawback Of Second Option.
15th Aug 2020, 7:56 AM
Rahul Saxena
Rahul Saxena - avatar