Answer to Question #280403 in Python for kika

Question #280403

2. Give at least three examples that show different features of string slices. Describe the feature illustrated by each example. Invent your own examples.


1
Expert's answer
2021-12-21T06:16:01-0500
#python slicing is about obtaining a substring, this can be done in different ways as illustrated in the examples below. Below are some featurs of string slices
#We can select letter in the string if know the index e.g
string = 'Joseph'
string[3]

'e'
#we can select more than one letter using the ':'
string = 'Joseph'
string[3:]

'eph'

string = 'Joseph'
string[:3]

'Jos'

#we can also get the reverse of the string up to a particular index
string = 'Joseph'
string[::-1]

'hpesoJ'

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS