- 3
What is the output of this code?
x = 'cool' print(x[-1] + x[-2] + x[-4] + x[-3])
3 Answers
+ 4
Pls remove all tags from your question, and include only one, with your code language. The answer depends on that. Also, tags are used to classify and search, so they should be informative.
Pls explain your difficulty. Is it when determinimg the items from the indexes? Is it in understanding the + sign in the context? On "print" behaviour? I don't kmow what you need help for.
+ 3
Manoj C S
The answer is loco as you would know if you ran the code.
This result is created through slicing of the string 'cool'
x[-1] = l
x[-2] = o
x[-4] = c
x[-3] = o
Because the outputs of the string are characters, the + indicates concatenation which joins the characters together to create a new string 'loco'
+ 2
Output:
loco