Counting as per Programming is Confusing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Counting as per Programming is Confusing

I have a doubt in Python So if we define a variable and assign some strings value eg: name = 'Hacker' As per Programming The first letter 'H' will carry zero (0) And 'r' will 5 When we use the function len(name) Why it will print 6 instead of 5

18th Aug 2020, 8:18 AM
Basudev
Basudev - avatar
2 Answers
+ 4
len function start Counting from 1 not from 0 But Indexing will start from 0.
18th Aug 2020, 8:21 AM
Ajith
Ajith - avatar
+ 2
Thanks for your answer 😀
18th Aug 2020, 8:23 AM
Basudev
Basudev - avatar