0

Does space”” has index?

str = "Hello world!" print(str[6]) If space has index, It should be printing space instead of w. Why does this happen?

10th Sep 2021, 1:00 AM
Ahchicuchi
Ahchicuchi - avatar
1 Respuesta
+ 6
Points to remember : ⏺️Every character in python has index it doesn't matter it's inside string or list. ⏺️indexing starts from 0 https://www.sololearn.com/learning/2431/ ------------------------------------------------- str="Hello world!" H=0 e=1 l=2 l=3 o=4 " " = 5 #space w=6 that's why str[6] printing 'w'.
10th Sep 2021, 1:46 AM
Ratnapal Shende
Ratnapal Shende - avatar