174k views
4 votes
Write a Python program string_functions.py that defines several functions. Each function re-implements Python's built-in string methods

User Walker
by
7.1k points

1 Answer

3 votes

Answer:

def length( mystring):

count = 0

for i in mystring:

count += 1

return count

def reversed( mystring):

strlist = []

for i in range(length(mystring)):

strlist.append(mystring[(length(mystring) - 1) - i])

txt = "".join(strlist)

return txt

string = 'Yolanda'

print(reversed(string))

Step-by-step explanation:

The python module defines two functions 'reversed' and 'length'. The length function counts the number of characters in a string variable while the reversed function reverses the string variable value.

User Dinesh Sonachalam
by
6.5k points