Z
Z
zelsky2016-04-01 10:03:24
Python
zelsky, 2016-04-01 10:03:24

How to remove a substring from a string by slice?

There is a string
x = 'asdasd asd asd asd asd as asd'
How to remove a substring from a string by type
slice[1:4]

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
angru, 2016-04-01
@zelsky

x = x[:1] + x[4:]
# or
x = '{}{}'.format(x[:1], x[4:])

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question