Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Question 1 100 pts Write a Python program that performs the following tasks: (1)

ID: 3722549 • Letter: Q

Question

Question 1 100 pts Write a Python program that performs the following tasks: (1) create a variable my-string, and assign '12a#43a5#6a9a#32' to it. Print the original my_string. (2) remove all '#'s from my-string using the replace method (replacing them to empty string). Update and print my string (3) Split my_string using the split method, assign the returned list to variable my list. Print my_list. Original string : 12a#43a5#6a9a#32 After replacement: 12a43a56a9a32 my list is ['12', '43', '56', '9', '32' HTML Editor Paragraph

Explanation / Answer

Hello There,

PFB python code for the required functionality along with the output of test run

prog.py

---------------------------------

#!/usr/bin/env python

import string

my_string = '12a#43a5#6a9a#32'
print("Original String: " + my_string)
my_string = string.replace(my_string, '#', '')
print("After Replacement: " + my_string)
my_list = my_string.split('a')
print("my_list is " + str(my_list))

--------------------------------------------------

TestRun:

--------------------------------------------------

$ ./prog.py
Original String: 12a#43a5#6a9a#32
After Replacement: 12a43a56a9a32
my_list is ['12', '43', '56', '9', '32']
$

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote