Code :
c = "clcoding"
print(c[:-2])
print(c[-2:])
Solution and Explanations:
here are the step-by-step solutions:
Step 1:
Define the variable c and assign the string "clcoding" to it.
c = "clcoding"
Step 2:
Print the substring of c that starts at the beginning of the string and goes up to the second to last character. This can be done using the slicing syntax c[:-2].
print(c[:-2])
Output:
clcodi
Step 3:
Print the substring of c that starts at the second to last character and goes up to the end of the string. This can be done using the slicing syntax c[-2:].
print(c[-2:])
Output:
ng
0 Comments:
Post a Comment