Python Question ixyzoo qi2 q is now xyzooxyzoo how do i repl

Python Question:

i=\'xyzoo\'

q=i*2

q is now xyzooxyzoo

how do i replace character z in the entire word or if it is more than one, to any other character. lets say to p.

for example, i want to change xyzooxyzoo to xypooxypoo

thanks

Solution

Answer: by using replace methd we can replace a \'z\' character.

i=\'xyzoo\'

q=i*2

p=q.replace(\'z\', \'\')

Output:

xypooxypoo

Python Question: i=\'xyzoo\' q=i*2 q is now xyzooxyzoo how do i replace character z in the entire word or if it is more than one, to any other character. lets s

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site