Advertisements
Advertisements
प्रश्न
Consider the statements given below and then choose the correct output from the given options:
myStr="MISSISSIPPI"
print(myStr[:4]+"#"+myStr[−5:])
विकल्प
MISSI#SIPPI
MISS#SIPPI
MISS#IPPIS
MISSI#IPPIS
MCQ
उत्तर
MISS#SIPPI
Explanation:
Mystr[:4] retrieves "MISS" characters from index 0 to 3, concatenated with "#". The mystr[−5:] slice returns characters from index −5 to the end, resulting in the string 'SIPPI'. In Python, indices range from 0 to n−1 (ahead) and −1...−n (reverse). The final string created is 'MISS#SIPPI'.
shaalaa.com
क्या इस प्रश्न या उत्तर में कोई त्रुटि है?