How to skip first two elements of string? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to skip first two elements of string?

How can I start indexing from 2nd element in string in python...please do help me

8th Oct 2021, 2:36 PM
Mr.MOHD RAFI
Mr.MOHD RAFI - avatar
3 Answers
+ 6
Learn how slicing works, it helps for such purposes https://www.sololearn.com/learn/JUMP_LINK__&&__Python__&&__JUMP_LINK/2453/
8th Oct 2021, 2:46 PM
Ipang
+ 5
str="abcdefgh" print(str[2:])
8th Oct 2021, 3:26 PM
SAN
SAN - avatar
+ 5
Mr.Mohd Rafi [FOLLOW ME] , if you wanted to address / access the second character of the string with index [0] you can do it like already mentioned by SAN like this: str="abcdefgh" print(str[2:][0]) => result is 'c'
8th Oct 2021, 3:51 PM
Lothar
Lothar - avatar