R
R
Ruslan Mordovanech2021-12-10 22:07:39
Python
Ruslan Mordovanech, 2021-12-10 22:07:39

How to enter two characters in replace () to replace one?

if d.upper().replace("\"", " ").replace("\'", " ") in i['case_involved'].upper().replace("\"", " ").replace("\'", " ")


How to shorten the painting, otherwise it seems to me that it is wrong to paint like this?
Thanks in advance.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vindicar, 2021-12-11
@Vindicar

Use str.maketrans() to create a lookup table and str.translate() to apply it to a string.
The upside is that with translate() you can also easily roll over replacements like "replace X with Y, and at the same time replace Y with X".

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question