Examine the code snippet below. What will be the contents of the variable `˜i' during the loops first iteration?
Examine the code snippet below. What will be the contents of the variable `˜i' during the loops first iteration?
The code snippet uses the split() method on the string 'Python is a powerful language', which splits the string into a list of words based on whitespace. The resulting list is ['Python', 'is', 'a', 'powerful', 'language']. During the first iteration of the loop, the variable 'i' will be assigned the first element of this list, which is 'Python'.
the split turns it into a list, defaults to space as separator. Thus python is first word
split() returns a list and splits on whitespace unless otherwise denoted. Python is in position [0], but the output will be Python.