Can somebody explain this code to me print('abcd' [-3,-1]). Thank youuu | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Can somebody explain this code to me print('abcd' [-3,-1]). Thank youuu

18th May 2020, 6:48 PM
Arcee
Arcee - avatar
3 Answers
+ 6
print('abcd' [-3:-1]) Last element is at index -1. So at index -3 you have 'b'. You need to move from index -3 to -1 (excluded). Hence it prints 'bc'.
18th May 2020, 6:57 PM
Avinesh
Avinesh - avatar
+ 5
hi, can you confirn it is 'abcd' [-3:-1] ?
18th May 2020, 6:57 PM
Oma Falk
Oma Falk - avatar
0
Thank you
18th May 2020, 7:33 PM
Arcee
Arcee - avatar