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

Please create the following functions in python and explain each step :) e) Writ

ID: 3606569 • Letter: P

Question

Please create the following functions in python and explain each step :)

e) Write a function that takes in a string and returns a string built from every even index from the original string (first, third, fifth, seventh, etc.) f) Write a function that takes in a string and returns a copy of the original string with all the repeated characters removed g) Write a function that takes in a string and returns a string that only contains the characters that were repeated in the entered string (e.g., Input: “112355fjshfsdaslhlsfnmbsdjkgf”, output: “15fjshdl”)

f) Write a function that takes in a string and returns a copy of the original string with all the repeated characters removed

g) Write a function that takes in a string and returns a string that only contains the characters that were repeated in the entered string (e.g., Input: “112355fjshfsdaslhlsfnmbsdjkgf”, output: “15fjshdl”)

Explanation / Answer

string = "hyderabad"

def even_index(string):
strOut = ""
for i in range(len(string)):
if(i%2==0):
strOut += string[i]
  
return strOut

def remove_Duplicates(string):
l = [x for x in string]
s = []
for i in l:
if i not in s:
s.append(i)
out = ""
for j in s:
out += j
return out
  
def only_Duplicates(string):
l = [x for x in string]
s = []
ss = []
for i in l:
if i not in s:
s.append(i)
else:
ss.append(i)
out = ""
for j in ss:
out += j
return out
  
print(even_index(string))   
print(remove_Duplicates(string))
print(only_Duplicates(string))

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