Question:medium

Consider the statements given below and then choose the correct output from the given options:
myStr = "MISSISSIPPI"
print(myStr[:4] + "#" + myStr[-5:])
    

Show Hint

In Python, positive indices count from the start (0), while negative indices count from the end (-1). Use them effectively for slicing strings.
Updated On: Jan 13, 2026
  • MISSI#SIPPI
     

  • MISS#SIPPI
     

  • MISS#IPPIS
     

  • MISSI#IPPIS

Show Solution

The Correct Option is B

Solution and Explanation

The code performs the following slicing operations:
  • myStr[:4] yields the initial 4 characters, "MISS".
  • myStr[-5:] yields the final 5 characters, "SIPPI".
  • Concatenating these substrings with "#" produces "MISS#SIPPI".
Was this answer helpful?
0