+ 8

What is the output of this code? print(str[0]) if str='Hello World'

2nd Jan 2018, 2:19 AM
Gerry Buron
Gerry Buron - avatar
2 Answers
- 1
It will print H because H is the first in the string array, str[1] is e, str[2] is l, and so on.
2nd Jan 2018, 2:43 AM
Spider38E
Spider38E - avatar
+ 1
you should use str_ or something entirely different as variable instead since its a type nominator. and end with : . if str_ would be "Hello World" then it would print H from str_ string. check docs about slicing for more info
16th Jan 2018, 2:25 AM
Markus Kaleton
Markus Kaleton - avatar